fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. struct A{
  6. A(){cout<<"+A "<<this<<endl;}
  7. ~A(){cout<<"-A "<<this<<endl;}
  8. virtual void test(){}
  9. };
  10. struct B:A{
  11. B(){cout<<"+B "<<this<<endl;}
  12. ~B(){cout<<"-B "<<this<<endl;}
  13. virtual void test(){}
  14. };
  15.  
  16. int main(){
  17. cout<<sizeof(A)<<" "<<sizeof(B)<<endl;
  18. {
  19. A *a=new B;
  20. delete a;
  21. }
  22. }
  23.  
Success #stdin #stdout 0s 4536KB
stdin
Standard input is empty
stdout
8 8
+A 0x55eba7b45e80
+B 0x55eba7b45e80
-A 0x55eba7b45e80