fork download
  1. #include <iostream>
  2.  
  3. struct test
  4. {
  5. test(int x)
  6. : a(get_b()),
  7. b(x)
  8. { }
  9.  
  10. int get_a() { return a; }
  11. int get_b() { return b; }
  12.  
  13. int a;
  14. int b;
  15. };
  16.  
  17. int main()
  18. {
  19. constexpr int expected = 3;
  20.  
  21. test t = expected;
  22.  
  23. if(t.get_a() != expected) {
  24. std::cout << "Expected " << expected << ", but got " << t.get_a() << std::endl;
  25. }
  26. }
  27.  
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Expected 3, but got 0