An empty try-catch-throw statement C++ program example


Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows XP Pro SP2

Header file: Standard

Additional project setting: Set project to be compiled as C++

Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C++ Code (/TP)

Other info:

To do: Try the caught an un-caught thrown exception

To show: An empty throw statement C++ source code sample




// An empty throw statement

#include <iostream>

using namespace std;


// this empty throw will be ignored...

void Nothing() throw()


cout<<"In Nothing(), empty throw..."<<endl;



void SomeType() throw(double)


cout<<"In SomeType, will throw a double type..."<<endl;




void main(void)







catch (double)


cout<<"Caught a double..."<<endl;




Output example:


In Nothing(), empty throw...

In SomeType, will throw a double type...

Caught a double...

Press any key to continue . . .



C and C++ Programming Resources | C & C++ Code Example Index