fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A {
  5. int a_, b_;
  6. constexpr A(int a): a_(a+a), b_(a*a) {}
  7. };
  8.  
  9. struct B {
  10. int a_, b_, c_;
  11. constexpr B(int x, int y): a_(x+y), b_(x-y), c_(x*y) {}
  12. };
  13.  
  14. struct R {
  15. int r_;
  16. R(int a, int b) : r_(a + rand()%(b-a)) {}
  17. };
  18.  
  19. struct C {
  20. static constexpr A a_ {3};
  21. static constexpr B b_ {4,5};
  22. static const R r_;
  23.  
  24. const R q_ {123,456};
  25. };
  26. const R C::r_ {100,500};
  27.  
  28. int main() {
  29. // your code goes here
  30. C c;
  31. cout << c.a_.a_ << " " << c.a_.b_ << endl;
  32. cout << c.b_.a_ << " " << c.b_.b_ << " " << c.b_.c_ << endl;
  33. cout << c.r_.r_ << " " << c.q_.r_ << endl;
  34. return 0;
  35. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
6 9
9 -1 20
283 454