online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> class Thing { public: // A: unchanged Thing(const int& val) : m_val(val) { } // B: calls getValue(), can't be const void printValue() { std::cout << "Value is " << getValue() << "\n"; } // C: non-const function can still return const reference to members const int& getValue() { return m_val; } // D: calling getValue on parameter, thus parameter can't be const void setValue(Thing& value) { m_val = value.getValue(); } private: int m_val; }; int main() { Thing thing1(1); Thing thing2(2); // Passed to non-const function, can't be const Thing thing3(3); // Calls non-const function, can't be const // Print original thing1.printValue(); thing2.printValue(); thing3.printValue(); // Set items thing1.setValue(thing2); thing3.setValue(thing2); // Print updated thing1.printValue(); thing2.printValue(); thing3.printValue(); return 0; // 0 = EXIT_SUCCESS }

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