online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> class X{ int val; public: X(int v){ std::cout<<"Constructor with value: "<<v<<"\n"; // no try - catch if(v<0){ std::cout<<"Invalid "<<v<<"\n"; throw 505; // exception code } std::cout<<"OK "<<v<<"\n"; this->val = v; } ~X(){ std::cout<<"Destructor with value: "<<this->val<<"\n"; } }; int main() { X *a, *b, *c; // try - catch try{ a = new X(900); b = new X(0); c = new X(-999); }catch(int e){ std::cout<<"Catch with exception code: "<<e<<"\n"; } delete c; // no effect delete a; delete b; return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue