online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include <memory> #include <optional> #include <vector> class Dest { public: std::optional<std::reference_wrapper<const int>> data; Dest(std::optional<std::reference_wrapper<const int>> data_arg) : data(data_arg) {} }; class Flowable { public: virtual ~Flowable() {} virtual void flow(Dest& dest) = 0; }; class Src : public Flowable { public: std::optional<std::reference_wrapper<const int>> data; Src(std::optional<std::reference_wrapper<const int>> data_arg) : data(data_arg) {} void flow(Dest& dest) { dest.data = data; } }; class ContFlowable : public Flowable { public: std::vector<std::unique_ptr<Flowable>> list; ContFlowable(std::vector<std::unique_ptr<Flowable>>&& list_arg) { list = std::move(list_arg); } void flow(Dest& dest) { for (std::unique_ptr<Flowable>& flowable : list) { flowable->flow(dest); } } }; void invoke_nasal_demons(ContFlowable& c) { int x1 = 15; Flowable* srcptr = dynamic_cast<Flowable*>(new Src { std::make_optional<std::reference_wrapper<const int>>(std::cref(x1)) }); c.list.push_back(std::unique_ptr<Flowable>(srcptr)); } int main() { int x2 = 20; ContFlowable c { std::vector<std::unique_ptr<Flowable>>() }; invoke_nasal_demons(c); Dest dest { std::make_optional<std::reference_wrapper<const int>>(std::cref(x2)) }; c.flow(dest); }

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