fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A
  5. {
  6. A()
  7. {
  8. cout << "A()" << endl;
  9. }
  10.  
  11. A(int x)
  12. {
  13. cout << "A(int)" << endl;
  14. }
  15.  
  16. A& operator=(int x)
  17. {
  18. cout << "A::operator=" << endl;
  19. }
  20. };
  21.  
  22. struct B
  23. {
  24. B() { a = 10; }
  25. A a;
  26. };
  27.  
  28. struct C
  29. {
  30. C() : a(10) {};
  31. A a;
  32. };
  33.  
  34. int main()
  35. {
  36. cout << "B" << endl;
  37. B b;
  38. cout << "C" << endl;
  39. C c;
  40. return 0;
  41. }
Success #stdin #stdout 0s 4304KB
stdin
Standard input is empty
stdout
B
A()
A::operator=
C
A(int)