Guest User

Untitled

a guest
Dec 11th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. class Base{
  2. public:
  3. virtual int get_data();
  4. virtual void set_data(int a);
  5. };
  6.  
  7. class ChildA : public Base
  8. {
  9. private:
  10. int a;
  11. ChildA * child;
  12. public:
  13. void set_object(ChildA& childa){ child = childa; }
  14. void set_data(int a){ this.a = a; }
  15. int get_data(){ return a; }
  16. }
  17.  
  18. class ChildB : public Base
  19. {
  20. ...
  21. }
  22. int main(){
  23. ChildA * childa = new ChildA;
  24. childa.set_object(childa);
  25. childa.set_data(12);
  26. ChildB * childb = new ChildB;
  27. childb.get_data();
  28. };
Add Comment
Please, Sign In to add comment