online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> template <class T> class comprehendTemplate { private: T val; public: comprehendTemplate(T num):val(num) { std::cout << "Parameterised Constructor" << std::endl; std::cout << "val " << val << std::endl; } comprehendTemplate(const comprehendTemplate& other) { std::cout << "Copy Constructor" << std::endl; val = other.val; } comprehendTemplate& operator=(const comprehendTemplate& other) { if (this != &other) { std::cout << "Assignment Operator Constructor" << std::endl; val = other.val; } return *this; } T getVal(){ return val; } }; int main() { comprehendTemplate <int>ct(9); comprehendTemplate <std::string>ct2("Hello"); std::cout << "getVal of ct " << ct.getVal() << std::endl; std::cout << "getVal of ct2 " << ct2.getVal() << std::endl; comprehendTemplate <std::string>ct3 = ct2; std::cout << "ct3 is a copy of ct2 " << ct3.getVal() << std::endl; comprehendTemplate <int>ct4(10); std::cout << "getVal of ct4 " << ct4.getVal() << std::endl; ct4 = ct; std::cout << "ct4 replaces the data with ct " << ct4.getVal() << std::endl; 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