fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Superclass {
  5. float& r;
  6. Superclass(float& r) : r(r) {
  7. cout << r << endl;
  8. }
  9. };
  10. class Class : public Superclass {
  11. float f;
  12. static float compute(float x, float y) {
  13. return x*x + y*y;
  14. }
  15. public:
  16. Class(float x, float y) : Superclass(f = compute(x, y)) {
  17. cout << f << endl;
  18. }
  19. };
  20.  
  21. int main() {
  22. Class c(3, 4);
  23. cout << c.r << endl;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 4304KB
stdin
Standard input is empty
stdout
25
25
25