Composition - Nathan-Groves/2143-OOP-Groves GitHub Wiki
Similar to inheritance in that it applies attributes of one class to another, but different in how it does so. In composition, an instance of a class is made in the definition of another class.
class Parent {
private:
int inheritance = 500;
public:
void printInheritance()
{
cout << inheritance;
}
};
class Child {
private:
Parent P;
public:
Child()
{
P.printInheritance();
}
};