Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Base{
- public:
- virtual int get_data();
- virtual void set_data(int a);
- };
- class ChildA : public Base
- {
- private:
- int a;
- ChildA * child;
- public:
- void set_object(ChildA& childa){ child = childa; }
- void set_data(int a){ this.a = a; }
- int get_data(){ return a; }
- }
- class ChildB : public Base
- {
- ...
- }
- int main(){
- ChildA * childa = new ChildA;
- childa.set_object(childa);
- childa.set_data(12);
- ChildB * childb = new ChildB;
- childb.get_data();
- };
Add Comment
Please, Sign In to add comment