c++ - Giving to child access to parent's member by reference - is it OK? -


C + newbie question please verify that I am correcting it.

I have a global application class which is producing it for small children and I have to give children the facility to use some facilities. That's why I decided to pass the children to them by reference.

I showed this idea as shown below. It seems to work fine. I just wanted to make sure that I am not doing anything dangerous

Dad makes children And gives them keys to their car:

  #include  TestHasKeys (); }  

I like it (if the keys are needed by them all). They may need some other services from Dad, which are requested later - such as:

  Wallet + = MyDad.GasMoney (REQUEST_MAX_AND_PROMISE_TO_BE_HOME_BY_10PM);  

But they have no reference to their father, so they will not be able to do that. Therefore, CChild Constructor will also refer to a this .

  Class IcashProvider {Public: Virtual Money Requests (iPERSON, CashRequest Flags); }; Class icfafer {public: virtual zero drive (iphurson []); };  

etc.

and then CChild to constructor ICashProvider and icfuffer , such as CWife and Cesar Friend (and CBoyfriend , maybe). At this point, I think that you can understand that this level of granularity is in vain in the face of father and you give it to everyone this and Dad sends the request to the caller for sending his own this in some ways, so you have to father make up or CWife diapers


Comments