Aggregation can be best described as an "IS-PART-OF"-relation. That is a relation which does not apply to classes derived from .ui-generated classes, as those .ui-generated classes are not a part of your dialog, but a simple parent for inheritance.
A good example for aggregation would be a car with an engine and tires:
// engine is-part-of a car
class Engine
{
};
// tire is-part-of a car
class Tire
{
};
// a car is build from tires and an engine
class Car
{
private:
Engine m_engine;
Tire* m_tires[4];
};
// and now inheritance:
// a Volkswagen is-a car
class Volkswagen : public Car
{
};
// engine is-part-of a car
class Engine
{
};
// tire is-part-of a car
class Tire
{
};
// a car is build from tires and an engine
class Car
{
private:
Engine m_engine;
Tire* m_tires[4];
};
// and now inheritance:
// a Volkswagen is-a car
class Volkswagen : public Car
{
};
To copy to clipboard, switch view to plain text mode
So, the basic difference between aggregation and inheritance boils down to:
1) Inheritance means you inherit something from one class to another (IS-KIND-OF or IS-A relationship)
2) Aggregation combines several simple parts to construct a more complex object (IS-PART-OF relationship)
Bookmarks