- 1
Multiple classes C++
I am doing a project and I have 3classes, I have an issue : how can use the instance of a class in another one. For example I want to read from file in one class, in the other one I want to use it. Please let me know if my question is not very clear. Thanks
4 Respostas
+ 1
If you know the concept of inheritance than you do that
https://www.sololearn.com/learn/CPlusPlus/1907/
If you don't understand from here than go to newboston channel on YouTube
+ 1
Thanks for your answer. I am kind of familiar with inheritance but wanted to solve without using inheritance. I am not sure if that is possible. I saw some examples about how to use other classes instances, but they didn't say to much to me. Thanks
+ 1
You could pick 1 or more of the following options:
Composition: https://www.learncpp.com/cpp-tutorial/102-composition/
Aggregation: https://www.learncpp.com/cpp-tutorial/103-aggregation/
or Association: https://www.learncpp.com/cpp-tutorial/10-4-association/
0
Thank you!