How do class objects access each other's functions and members in c++? I have all the classes I need, but I'm still wondering what the "standard" way of having them communicate and interact is.
A function in object A creates an instance (or receives a reference) of object B. It then calls a function in object B and passes whatever data is required...
Well execution of the program always starts at a function called main().
main() then creates whatever objects it needs and then those objects might create and call other objects... but main() only knows about the objects that it explicitely created.
Once all control paths return back to main() and there are no more instructions left to run in main() (or if exit() or return are called) the program ends.
You can have objects that are subclasses of other objects, so they automatically have all the methods of the original class unless explicitly replaced plus any methods you choose to give them.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.