Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1.  class X {
  2. protected:
  3.     const static int i = 1;
  4.     public:
  5.    void print() {cout << i;}
  6. };
  7.  
  8. class Y : public X {
  9.     const static int i = 2;
  10. public:
  11.     void print() {cout << i;}
  12. };
  13.  
  14. int main(int argc, char* argv[]) {
  15.     Y y;
  16.     y.print();
  17.     ((X)y).print();
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement