what syntax calling method in owning object owned object in c++?
parent class:
class parent { private: child child; public: parent() { addchild(child); } void methodtobecalled(int someargument) { } };
child class:
class child { private: void myvoid() { //call parent method somehow } public: child() { } };
i tried make question simple , generic possible (to of benefit many possible). let me know if can make clearer.
thank you!
here's example. had modify code bit compile:
class component {}; class parent; class child : public component { private: inline void myvoid(); parent &parent_ref; public: child(parent &pr) : parent_ref{pr} {} }; class parent : public component { private: child child; public: parent() : child{*this} { // addchildcomponent(child); } void methodtobecalled(int someargument) { } }; inline void child::myvoid() { parent_ref.methodtobecalled(1); }
Comments
Post a Comment