online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <vector> #include<memory> #include<iostream> class Foo { public: Foo(int i) : i(i) {} using Ptr = std::shared_ptr<Foo>; //private: int i; }; class Bar { public: inline static const std::vector<Foo::Ptr> foos{ std::make_shared<Foo>(1), std::make_shared<Foo>(2), std::make_shared<Foo>(3)}; }; int main() { Bar b; for(auto x : b.foos) { std::cout<< x->i << std::endl; x->i += 1; } std::cout << "changed" << std::endl; for(auto x : b.foos) { std::cout<< x->i << std::endl; } // b.foos.push_back(std::make_shared<Foo>(12)); 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