Guest User

Untitled

a guest
Sep 10th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class A {
  4.     int n;
  5. protected:
  6.    A(int i) : n(i) { }
  7.    virtual int get() = 0;
  8.    virtual void print() = 0;
  9. };
  10.  
  11. int A::get() {
  12.     return n;
  13. }
  14.  
  15. class B : private A {
  16. protected:
  17.     B(int i) : A(i) {}
  18.  
  19.    //insert code here
  20.  
  21. };  // End of class B
  22.  
  23. class C : public B {
  24. public:
  25.     C(int i) : B(i) {}
  26.     void print() {
  27.         cout << get() ;
  28.     }
  29. };
  30.  
  31. int main(){
  32.     int n;
  33.     cin >> n;
  34.     C *p = new C(n);
  35.     p->print();
  36.     return 0;
  37. }
Add Comment
Please, Sign In to add comment