+ 1
Can I use a class as a member of an other class? Does it make sense?
In C, when I had a " struct point{ int x; int y; }; " structure, it was a good practice when I made a triangle using the 'point': struct triangle{ struct point A; struct point B; struct point C; }; But in C++ classes may contain functions, unlike struct. So, does it make sense if I do the same with classes, or should I use struct? What if 'class Point' has a member function? Which is the preferred way? Do I have to inherit a class instead of nesting into another class?
1 ответ
+ 2
Yes we can do that.
For more info go to
http://stackoverflow.com/questions/10576334/a-class-as-data-member-of-another-class
this will help someway :)