Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3.  
  4. using namespace std;
  5.  
  6. struct A {
  7.     float x;
  8.     A(float a = 0) { x = a; cout << 1; }
  9.     ~A() { cout << 2; }
  10. };
  11.  
  12. struct B: A {
  13.     float x;
  14.     B(float a = 0) { x = a; cout << 3; }
  15.     ~B() { cout << 4; }
  16. };
  17.  
  18. struct C: B{
  19.     float x;
  20.     C(float a = 0) { x = a; cout << 5; }
  21.     virtual ~C() { cout << 6; }
  22. };
  23.  
  24. struct D: C {
  25.     float x;
  26.     D(float a = 0) { x = a; cout << 7; }
  27.     virtual ~D() { cout << 8; }
  28. };
  29.  
  30. void f() { cout << endl; }
  31.  
  32. int main(void) {
  33.     B *p = new D; f();
  34.     delete p; f();
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement