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》书中的观点能有些启发吧!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值