fork download
  1. #include <iostream>
  2.  
  3. class Base{
  4. public:
  5. const static int Public= 0x01;
  6. protected:
  7. static const int Protected = 0x02;
  8. private:
  9. static const int Private = 0x03;
  10. public:
  11.  
  12. Base(){}
  13.  
  14. void hoge(){
  15. std::cout<<Public<<std::endl;
  16. std::cout<<Protected<<std::endl;
  17. std::cout<<Private<<std::endl;
  18. }
  19. };
  20.  
  21. class Derived:public Base{
  22. public:
  23. Derived(){}
  24. void huga(){
  25. std::cout<<Public<<std::endl;
  26. std::cout<<Protected<<std::endl;
  27. //std::cout<<Private<<std::endl;
  28. }
  29. };
  30.  
  31.  
  32. int main(){
  33. Derived D;
  34.  
  35. D.hoge();
  36. D.huga();
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
1
2
3
1
2