The relationships between classes and classes are:
1. Related relations;
2, the combination of relations;
3, the aggregation relationship;
4, the dependence relationship;
5, inheritance relations;
6, the realization of the relationship;
Among them, the combination relation and the aggregation relation are the special correlation relations.
Association relationship:
A->b a association B is a one-way association, if b->a, it forms two-way association;
Semantics: a knows a B
Code form:
Class a{
B *m_b;
}
The combination relationship and the aggregation relationship are the same in the code form and the correlation, but the semantics are different:
The semantics of combinatorial relationships: A contains a B, A is dead, B is not alive;
The semantics of the aggregation relationship: A contains a B, A is dead, B can live;
Inheritance Relationship:
Semantics: B is a kind of a
Code form:
Class B:a
{
}
In the realization relation, the implementation is often an interface (interface), the code form is the same as the inheritance relation;
Dependency Relationship:
Semantics: A uses a B
Code form:
Class a{
Method (B &b);
}
The relationships between classes