Advertisement
Felanpro

Protected

Apr 12th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Father //Base class
  6. {
  7. public:
  8. protected:
  9.     int protectedv;
  10. };
  11.  
  12. class Child : Father //Derived class //Inheriting from other classes lets you use
  13. {                                    //the other class protected members!
  14. public:
  15.     void doSomething();
  16. };
  17.  
  18. int main()
  19. {
  20.     Child FuckedUpKid;
  21.     FuckedUpKid.doSomething();
  22. }
  23.  
  24. void Child::doSomething()
  25. {
  26.     protectedv = 13;
  27.     cout << protectedv << endl;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement