Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: e32base.h
Link against: euser.lib

Class CBase

CBase

Support

Supported from 5.0

Description

Base class for all classes to be instantiated on the heap.

By convention, all classes derived from CBase have a name beginning with the letter 'C'.

The class has two important features:

A virtual destructor - this allows instances of derived classes to be destroyed and properly cleaned up through a CBase* pointer. All CBase derived objects can be pushed, as CBase* pointers, onto the cleanup stack, and destroyed through a call to CleanupStack::PopAndDestroy().

Initialisation of the CBase derived object to binary zeroes through a specific CBase::operator new() - this means that members, whose initial value should be zero, do not have to be initialised in the constructor. This allows safe destruction of a partially-constructed object.

Defined in CBase:
operator new(), ~CBase()

See also:


Construction and destruction


~CBase()

virtual ~CBase();

Description

Enables any derived object to be deleted through a CBase* pointer.

[Top]


Allocation


operator new()

TAny* operator new(TUint aSize,TAny* aBase);
TAny* operator new(TUint aSize,TLeave aLeave);
TAny* operator new(TUint aSize);
TAny* operator new(TUint aSize,TUint anExtraSize);

Description

Allocates the object from the heap and then initialises its contents to binary zeroes.

Parameters

TUint aSize

The size of the derived class. This parameter is specified implicitly by C++ in all circumstances in which a derived class is allocated.

TLeave aLeave

If specified as ELeave, indicates that the operation leaves if allocation fails with out-of-memory. If not specified, the operation returns a zero pointer if allocation fails with out-of-memory.

TAny* aBase

If specified, indicates a base address which is returned as the object’s address. Use of this form is rare.

TUint anExtraSize

If specified, indicates additional size beyond the end of the base class. Use of this form is rare..

Return value

TAny*

A pointer to the allocated object