codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> using namespace std; class Test{ public: int m_ID; Test Make(int ID){ return Test(ID); } Test operator + (Test &o){ return Test(m_ID+o.m_ID); } Test(int id) : m_ID(id){ cout << "Created Object " << m_ID << endl; } ~Test(){ cout << "Destroyed Object " << m_ID << endl; } }; int main(int argc, char **argv){ Test A = Test(10); Test B = A.Make(11); Test C = A+B; cout << "Object: "<<A.m_ID<<endl; cout << "Object: "<<B.m_ID<<endl; cout << "Object: "<<C.m_ID<<endl; return 0; }
Private
[
?
]
Run code
Submit