fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A
  5. {
  6. private:
  7. int a = 1;
  8. public:
  9. int b = 3;
  10. };
  11.  
  12. class B : public A
  13. {
  14. public:
  15. int b = 4;
  16. };
  17.  
  18. int main() {
  19. // your code goes here
  20. B* b = new B();
  21. cout << static_cast<A*>(b)->b << endl;
  22. return 0;
  23. }
Success #stdin #stdout 0s 4524KB
stdin
Standard input is empty
stdout
3