Last active
March 28, 2019 00:36
-
-
Save kkabdol/dfcd78a3529bef44fc9b2855465db196 to your computer and use it in GitHub Desktop.
Constructs In Hierarchy (Review the last test)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| class A | |
| { | |
| public: | |
| A() { cout << "A()" << endl; } | |
| ~A() { cout << "~A()" << endl; } | |
| }; | |
| class B : public A | |
| { | |
| public: | |
| B() { cout << "B()" << endl; } | |
| B(int arg) { cout << "B(arg)" << endl; } | |
| ~B() { cout << "~B()" << endl; } | |
| }; | |
| int main() { | |
| B b(10); | |
| // Output | |
| // | |
| // A() | |
| // B(arg) | |
| // ~B() | |
| // ~A() | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment