fork download
  1. #include <iostream>
  2. using namespace std;
  3. class Base
  4. {
  5. public:
  6. Base(int a_, int b_, int c_):a(a_),b(b_),c(c_)
  7. {}
  8. public:
  9. int a;
  10. protected:
  11. int b;
  12. private:
  13. int c;
  14. };
  15.  
  16. class Derived: public Base
  17. {
  18. public:
  19. Derived(int a_, int b_, int c_):Base{a_,b_,c_}
  20. {}
  21. void func()
  22. {
  23. cout<<"a "<<a<<endl;
  24. cout<<"b "<<b<<endl;
  25. //cout<<"c "<<c<<endl;
  26. }
  27. void print(const Derived& d)
  28. {
  29. cout<<"bkbbbbb"<<endl;
  30. cout<<"d1 "<<d.a<<endl;
  31. cout<<"d2 "<<d.b<<endl;
  32. }
  33.  
  34.  
  35. };
  36. int main() {
  37. // your code goes here
  38. Derived d{1,2,3};
  39. d.func();
  40. d.a = 10;
  41. d.func();
  42. d.print(d);
  43. return 0;
  44. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
a 1
b 2
a 10
b 2
bkbbbbb
d1 10
d2 2