fork download
  1. #include <iostream>
  2. class Base
  3. {
  4. int s{9};
  5. public:
  6. operator int()
  7. {
  8. return s;
  9. }
  10. };
  11. class Derived : public Base
  12. {
  13. int s{18};
  14. };
  15. int main()
  16. {
  17. Base b;
  18. int s=b;
  19. std::cout<<s<<'\n';
  20.  
  21. Derived d;
  22. int m=d;
  23. std::cout<<m;
  24. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
9
9