Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Test01 {
- public:
- int value;
- Test01(int v=0): value(v) { cout << "Test01 " << value << " Constructor;\n"; }
- Test01(const Test01 &T): value(T.value) { cout << "Test01 " << value << " Copy Constructor;\n"; }
- ~Test01(){ cout << "Test01 " << value << " Destructor;\n"; }
- Test01 & operator= (const Test01 &T){ cout << "Test01 " << value << " Assignment Operator;\n"; value = T.value; return *this; }
- };
- class Test02 : public Test01 {
- public:
- Test02(int v=0): Test01(v){ cout << "Test02 " << value << " Constructor;\n"; }
- //Test02(const Test02 &T){ cout << "Test02 " << value << " Copy Constructor;\n"; }
- ~Test02(){ cout << "Test02 " << value << " Destructor;\n"; }
- };
- int main(){
- Test02 a(3);
- cout << "a: " << a.value << "\n";
- Test02 b = a;
- cout << "b: " << b.value << "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement