fork download
  1. #define THREE
  2.  
  3. struct Base {
  4. int t_size;
  5. Base (int i) : t_size(i) {}
  6. virtual ~Base () {}
  7. int size () const { return t_size; };
  8. };
  9.  
  10. struct D1 : virtual Base {
  11. int a[10];
  12. D1 () : Base(0) {}
  13. ~D1 () {}
  14. };
  15. struct D2 : virtual Base {
  16. int a[20];
  17. D2() : Base(0) {}
  18. ~D2 () {}
  19. };
  20.  
  21. #ifdef ONE
  22. struct Derived : Base
  23. #endif
  24. #ifdef TWO
  25. struct Derived : virtual Base
  26. #endif
  27. #ifdef THREE
  28. struct Derived : D1, D2
  29. #endif
  30. {
  31. Derived () : Base(0) {}
  32. ~Derived () {}
  33. int a[100];
  34. };
  35.  
  36.  
  37. void foo (Derived *p)
  38. {
  39. if(p->size())
  40. return;
  41. p = 0;
  42. }
  43.  
  44. int main ()
  45. {
  46. Derived d;
  47. foo(&d);
  48. }
  49.  
Success #stdin #stdout 0.01s 2720KB
stdin
Standard input is empty
stdout
Standard output is empty