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