The Relationships Between Classes in Symbian OS C++ for Mobile Phones Volume 3

As you’d expect, classes are used to represent objects, abstractions and interfaces. Relationships between classes are used to represent relationships between objects or abstractions. The most important relationships between classes are:

uses-a: if class A ‘uses-a’ class B, then A has a member of type B, B&, const B&, B* or const B*, or a function that can easily return a B in one of these guises; A can then use B’s member functions and data.

has-a: ‘has-a’ is like ‘uses-a’, except that A takes responsibility for constructing and destroying the B as well as using it during its lifetime

is-a: ifclass A ‘is-a’ class B, then B should be an abstraction of A; ‘is-a’ relationships are usually represented in C++ using public derivation

implements: if class A implements an interface M, then it implements all M’s pure virtual functions; this is the only circumstance in which multiple inheritance is used in Symbian OS.

面向对象中,类与类之间的关系有些是不好把握的,《Symbian OS C++ for Mobile Phones Volume 3》书中的观点能有些启发吧!

你可能感兴趣的:(The Relationships Between Classes in Symbian OS C++ for Mobile Phones Volume 3)