what is the concept of inheritance and aggregation in c++?
1) Intuitive Understanding if we have a class called A, which is class A{...}; inheritance like this: class B: public A {...}; aggregation like this: class B{ A some_a; }; 2) Concept Firstly, one of aims of Inheritance and Aggregation is to compartmentalize and reuse code, but they still have differences between each others. Inheritance imply a "is-a" or "is-kind-of" relationship between subclass and super class, e.g. Square is kind of Rectagle,so you can design like: class Square: pulic Rectangle{...}; Aggregation imply a "has-a" relationship between two classes, e.g. a group of person is aggregated by many persons, so you can design like: class PersonGroup { PersonList many_many_Person;}; in sum, there are many differences bwtween them, whether in semantics or in implement, i hope that i can help you . if i have some error, please let me kown, thank you. btw, it's better if my poor english won't confuse you.
Join our real-time social learning platform and learn together with your friends!