Skip to content

Instantly share code, notes, and snippets.

@kkabdol
Last active March 28, 2019 00:36
Show Gist options
  • Select an option

  • Save kkabdol/dfcd78a3529bef44fc9b2855465db196 to your computer and use it in GitHub Desktop.

Select an option

Save kkabdol/dfcd78a3529bef44fc9b2855465db196 to your computer and use it in GitHub Desktop.
Constructs In Hierarchy (Review the last test)
#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