| | |
throwing statement in derived class constructor
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2008
Posts: 119
Reputation:
Solved Threads: 10
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:
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
i mean:
C++ Syntax (Toggle Plain Text)
void functionx() throw ( exception1 , exception 2) { //blabla throw exception1; //blabla throw exception2; }
because
B::B() : a() throw ( exception1 , exception2 )
gives the
errorr C2612: trailing 'throw' illegal in base/member initializer list
thx
Last edited by Ancient Dragon; Jan 30th, 2008 at 7:14 am. Reason: add code tags
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
c++ Syntax (Toggle Plain Text)
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) {}
•
•
Join Date: Jan 2008
Posts: 119
Reputation:
Solved Threads: 10
•
•
•
•
c++ Syntax (Toggle Plain Text)
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) {}
![]() |
Other Threads in the C++ Forum
- Previous Thread: MFC and CSpreadSheet: Exporting to a text file
- Next Thread: Lost toolbar after minimize
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion count data database delete deploy desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez graph homeworkhelp homeworkhelper iamthwee ifstream input int integer lib linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






