分类: C/C++
2008-05-03 00:49:56
The ‘T’ type is a value type, owning no external object. T类型表示是一个基本类型,就好像int,char一样。
The ‘R’ type is a resource type; typically this is proxy for an object owned elsewhere. In practice, the 'R' type is a handle to a resource owned and managed by the Kernel. R类型表示对某种资源的封装。
This shows a typical ‘C’ class, derived from CBase, and highlights the use of two phase construction and use of the cleanup stack to implement the complete construction of an instance of that class on the heap. C类型从CBase继承而来,任何C类型都在heap上构造,需要两步构造和使用CleanupStack来帮你管理内存。
The three examples show the use of ‘M’ (abstract interface) classes, the only type of multiple inheritance used in Symbian OS.They show how interfaces can be used to define a protocol. The interface is implemented by a protocol provider, and called by a protocol user. The user is not supposed to know anything about the provider's implementation, only about the protocol it's interested in. M类型定义了一个抽象接口,Symbian中的多重继承都会看到M类型的影子。相当于给Derived Class定义了一个接口,那么在Symbian中看到了多重继承却没有看到M类型,合理吗?
最后,来看看CBase这个经常在你面前晃悠的东西吧。
CBase是所有要在heap上构造的基类,所有CBase的子类名都以C开头。具有两个重要特性:a)析构函数是虚的;b)通过CBase::operator new()的特殊版本给所有C类型变量初始化为0,不要担心构造函数没给这些变量初始化啦,这样即使出现异常,已经部分初始化的对象也能得以体面地析构。
问题:
多重继承的时候有没有顺序要求呢?
class CProtocolProvider : public CBase, public MProtocol
CBase必须在MProtocol前面吗?为什么?