online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <functional> class Parent { public: virtual void say() const { std::cout<<"I am parent"<<"\n"; } }; class Child: public Parent { public: void say() const { std::cout<<"I am child"<<"\n"; } }; using Wrapper = std::function<void(const Parent&)>; int main() { Wrapper func=[](const Parent& parent){ auto child=dynamic_cast<const Child*>(&parent); if (child) child->say(); else std::cout<<"OUCH!!! I need a child"<<std::endl; }; Parent x; Child c; std::cout<<"For a child: "; func(c); std::cout<<"For a parent: "; func(x); 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