Original: http://discussion.forum.nokia.com/forum/showthread.php?t=68969
Translated from developer Library»symbian OS guide»essential idioms»class types
Profile
Applications on Symbian OS use 4 commonly used classes, which are:
A value class that begins with T, which does not own any external objects, but refers directly to or indirectly through a handle to an external object.
A heap-allocation class that starts with C, which is all derived from CBase.
A resource class that begins with R, and the R class object contains a handle to a resource in another location.
An interface class that begins with M that defines an interface but requires a derived class implementation.
These classes are related to the requirements of the Purge mechanism, please refer to the SDK (Developer Library»symbian OS guide»c++ API guide»base»memory management»using Cleanup S Upport»cleanup Stack basics»cleanup requirements).
Value type: T class
The most basic classes are value types, and their names begin with T.
The T class contains their values, but they do not own any external objects, but simply refer directly to them through the pointer or indirectly refer to an external object through a handle.
The T class can be allocated on the stack (c + + automatic variables), or it can be members of other classes.
The basic features of the T class are described below.
constructor function:
Many of the T classes are so simple that constructors are not needed at all, and those that contain constructors initialize member data through constructors.
Copy constructors and assignment operators:
Copy Constructors (TX (const tx&)) and assignment operators (tx& operator= (const tx&) are rarely needed because copies are shallow copies, and T classes are almost always copied by members. The C + + compiler produces the default copy constructor and assignment operator.
These two functions are required when the T class is a template class that has an integer parameter, in which case the copy or assignment tx<32> to the tx<40> is more complex than the bitwise copy, so the copy constructor and assignment operator need to be explicitly implemented.
destructor:
The T class does not require a destructor, because there is no external resource that needs to be purged when the T class life cycle ends.
Destroy
The T class can be safely destroyed on the stack, which means that the memory can be freed without the destructor. Because the T class does not own external resources, there is no access to external resources when the class T object is destroyed.
function arguments
As a function parameter, the T class can be passed by value and reference.
Data members
The T class can contain other T-class objects and, in addition, can contain pointers to R-class objects or C-class objects that are cleared by another class or function, and are rarely used in practice.
Standard class level: Class C and CBase
The classes that use the most are in addition to the T class and the C class, which derives directly or indirectly from the CBase class.