Add a pointer of your parent class in your child class, change the constructors to pass the parent pointer. Once you have the parent pointer inside child you can easily access any public method of parent.
Add a pointer of your parent class in your child class, change the constructors to pass the parent pointer. Once you have the parent pointer inside child you can easily access any public method of parent.
You can do this, but it makes the parent-child system highly coupled. This is not a good situation to be in as the design is not flexible, and is not modular. Now you cannot use your child component anywhere - it must be used with only specific parents.
When this happens you should be looking at doing some dependency inversion
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
Bookmarks