online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <iostream> using namespace std; template <typename T> class WrapperPtr { T * ptr; public: WrapperPtr(const WrapperPtr&){ // ??? } WrapperPtr(WrapperPtr&&) { // ??? } WrapperPtr(const T & other) : ptr(new T(other)) {} WrapperPtr(T * other) : ptr(other) {} ~WrapperPtr() { // ???? delete ptr; } T * operator -> () { return ptr; } T & operator * () { return *ptr; } const T & operator * () const { return *ptr; } bool operator == (T other) const { other == *ptr; } operator T () { return *ptr; } }; class X { int x; public: X(int x) : x(x) {} void foo () { std::cout << "X::foo();\n"; } int bar (std::string s) { std::cout << "X::bar(" << s << ");\n"; } }; // an example templated functio template <typename T> bool my_is_same(const T& t1, const T& t2) { return t1 == t2;} // second invocation fails due to template substitution failure bool problem() { WrapperPtr<int> w(5); return my_is_same(static_cast<int>(w), 5) && my_is_same(*w, 5); } int main() { WrapperPtr<X> w(new X(5)); w->foo(); w->bar("hello"); 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