fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A {
  5. public:
  6. float v;
  7. A(float x) : v(x) {}
  8. };
  9.  
  10. class B {
  11. public:
  12. A a;
  13. float b;
  14. B(float x) : a(x + 1) { b = a.v; }
  15. };
  16.  
  17. int main() {
  18. B b(2.0);
  19. cout << b.b;
  20. return 0;
  21. }
Success #stdin #stdout 0s 15224KB
stdin
Standard input is empty
stdout
3