Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- using namespace std;
- struct A {
- float x;
- A(float a = 0) { x = a; cout << 1; }
- ~A() { cout << 2; }
- };
- struct B: A {
- float x;
- B(float a = 0) { x = a; cout << 3; }
- ~B() { cout << 4; }
- };
- struct C: B{
- float x;
- C(float a = 0) { x = a; cout << 5; }
- virtual ~C() { cout << 6; }
- };
- struct D: C {
- float x;
- D(float a = 0) { x = a; cout << 7; }
- virtual ~D() { cout << 8; }
- };
- void f() { cout << endl; }
- int main(void) {
- B *p = new D; f();
- delete p; f();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement