online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <functional> #include <string> #include <iostream> #include <memory> using namespace std; class A { public : function<void()> fn(string str){ // (2) struct closure { int num; }; auto ptr = make_shared<closure>(); ptr->num = 99; auto fn = [=](){ ptr->num++; cout << ptr->num << " -- " << str << endl; };//fn return fn; }//fn };//A A a; int main(){ auto fn = a.fn("1"); fn(); fn(); auto fn2 = a.fn("2"); fn2(); fn2(); return 0; }//main

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