fork download
  1. #include <iostream>
  2.  
  3. struct A {
  4. A() { std::cout << "A()" << std::endl; }
  5. A(int) { std::cout << "A(int)" << std::endl; }
  6. A(const A&) { std::cout << "A(const A&)" << std::endl; }
  7. A& operator=(const A&) { std::cout << "A=()" << std::endl; return *this; }
  8. ~A() { std::cout << "~A()" << std::endl; }
  9. };
  10.  
  11. struct B {
  12. B() { std::cout << "B()" << std::endl; }
  13. B(int) { std::cout << "B(int)" << std::endl; }
  14. B(const B&) { std::cout << "B(const B&)" << std::endl; }
  15. ~B() { std::cout << "~B()" << std::endl; }
  16. B& operator=(const B&) { std::cout << "B=()" << std::endl; return *this; }
  17. };
  18.  
  19. struct C {
  20. B b;
  21. A a1;
  22. A a2;
  23. C() : a1(3){
  24. b = 3;
  25. a2 = 7;
  26. }
  27. };
  28.  
  29. int main(){
  30. C c;
  31. return 0;
  32. }
Success #stdin #stdout 0s 4700KB
stdin
Standard input is empty
stdout
B()
A(int)
A()
B(int)
B=()
~B()
A(int)
A=()
~A()
~A()
~A()
~B()