online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> struct Base { int common = 0; Base(int common):common(common) { } // das "operative" Interface meiner Ableitungen virtual void behavior() = 0; // polymorph clonen virtual Base* clone() = 0; // nur als Debug-Hilfe virtual void info() { std::cout << "Base int common: " << common << std::endl;; } }; struct TypeA: Base { TypeA(int common, int value):Base(common),value(value){} int value = 0; virtual void behavior() { common += 2; value *= 2; }; virtual Base* clone() { return new TypeA(*this); } virtual void info() { Base::info(); std::cout << "TypeA int value: " << value << std::endl;; } }; struct TypeB: Base { TypeB(int common, double value):Base(common),value(value){} double value = 0.0; virtual void behavior() { common += 2; value *= 2.0; }; virtual Base* clone() { return new TypeB(*this); } virtual void info() { Base::info(); std::cout << "TypeB double value: " << value << std::endl;; } }; void CloneAndReassigne(Base* original) { std::cout << "CloneAndReassigne" << std::endl; Base* clone = original->clone(); std::cout << "Original:" << std::endl; original->info(); clone->behavior(); std::cout << "Clone nach Aenderung:" << std::endl; clone->info(); *original = *clone; std::cout << "Original nach Aenderung:" << std::endl; original->info(); } int main() { TypeA a(1, 2); TypeB b(2, 4); CloneAndReassigne(&a); CloneAndReassigne(&b); }

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