Tranvick

Example9

Jan 8th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. //Пример 9. Классы:
  2. //наследование; управление доступом; множественное наследование
  3.  
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. class A {
  9. public:
  10.     void print1() {
  11.         cout << "class A\n";
  12.     }
  13. };
  14.  
  15. class B {
  16. public:
  17.     void print2() {
  18.         cout << "class B\n";
  19.     }
  20. };
  21.  
  22. class C : public A, protected B {
  23. public:
  24.     void print3() {
  25.         cout << "class C\n";
  26.     }
  27.     void print_() {
  28.         print2();
  29.     }
  30. };
  31.  
  32. int main() {
  33.     C x;
  34.     x.print1();
  35. //  x.print2();
  36.     x.print_();
  37.     x.print3();
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment