fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A{
  5. protected:
  6. int x;
  7. public:
  8. void zmien_x()
  9. {
  10. x=20;
  11. cout << x<< endl;
  12. }
  13.  
  14. int zwroc()
  15. {
  16. return x;
  17. }
  18. };
  19.  
  20. class B: public A
  21. {
  22. public:
  23. void wys_x()
  24. {
  25. cout << x+10 << endl;
  26. cout << zwroc()+10 << endl;
  27. }
  28.  
  29.  
  30. };
  31.  
  32.  
  33. int main()
  34. {
  35. A obiekt;
  36. B o;
  37. obiekt.zmien_x();
  38. cout << obiekt.zwroc();
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
20
20