0

i noticed that when u compile with visual C++ u don't need the throw statement in function headers, but when u compile with g++ u need to explicitly mention all the exceptions u're function might throw.
i mean:

void functionx() throw ( exception1 , exception 2)
{
//blabla
throw exception1;
//blabla
throw exception2;
}

but if u have a base class A and a derived class B, how do u write the throw statement for the B class constructor?
because

B::B() : a() throw ( exception1 , exception2 )
gives the
errorr C2612: trailing 'throw' illegal in base/member initializer list

thx

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by kux
1
struct A
{
  A( int i ) throw(char,int,double) : value(i) {}
  int value ;
};

struct B : A
{
  B() throw(char,int,double) ;
};

B::B() throw(char,int,double) : A(20) {}
Votes + Comments
Nice
0
struct A
{
  A( int i ) throw(char,int,double) : value(i) {}
  int value ;
};

struct B : A
{
  B() throw(char,int,double) ;
};

B::B() throw(char,int,double) : A(20) {}

thx

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.