fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Base{
  6. public:
  7. string s;
  8. };
  9.  
  10. class Derived : public Base{
  11. public:
  12. string y;
  13. void foo(){ cout << s << endl << y << endl;}
  14. };
  15.  
  16. int main() {
  17. Derived a;
  18. a.s = "Hi";
  19. a.y = "Friend!";
  20. a.foo();
  21. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
Hi
Friend!