Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <e32base.h>
Link against: euser.lib

Class CBase

class CBase;

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:

1. A virtual destructor that 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().

2. Initialisation of the CBase derived object to binary zeroes through a specific CBase::operator new(TUint,TAny *) - 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.

Note that using C++ arrays of CBase-derived types is not recommended, as objects in the array will not be zero-initialised (as there is no operator new[] member). You should use an array class such as RPointerArray instead for arrays of CBase-derived types.

Members

Defined in CBase:

See also:


Construction and destruction


CBase()

inline CBase();

Description

Default constructor


~CBase()

IMPORT_C virtual ~CBase();

Description

Virtual destructor.

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

[Top]


Member functions


operator new(TUint,TAny *)

inline TAny* operator new(TUint aSize, TAny *aBase) __NO_THROW;

Description

Initialises the object 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.

TAny *aBase

Indicates a base address which is returned as the object's address.

Return value

TAny *

A pointer to the base address.


operator new(TUint)

inline TAny* operator new(TUint aSize) __NO_THROW;

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.

Return value

TAny *

A pointer to the allocated object; NULL if memory could not be allocated.


operator new(TUint,TLeave)

inline TAny* operator new(TUint aSize, TLeave);

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

Return value

TAny *

A pointer to the allocated object; the TLeave parameter indicates that the operation leaves if allocation fails with out-of-memory.


operator new(TUint,TUint)

inline TAny* operator new(TUint aSize, TUint aExtraSize) __NO_THROW;

Description

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

Use of this overload is rare.

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.

TUint aExtraSize

Indicates additional size beyond the end of the base class.

Return value

TAny *

A pointer to the allocated object; NULL if memory could not be allocated.


operator new(TUint,TLeave,TUint)

inline TAny* operator new(TUint aSize, TLeave, TUint aExtraSize);

Description

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

Use of this overload is rare.

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

TUint aExtraSize

Indicates additional size beyond the end of the base class.

Return value

TAny *

A pointer to the allocated object; the TLeave parameter indicates that the operation leaves if allocation fails with out-of-memory.


Delete(CBase *)

IMPORT_C static void Delete(CBase *aPtr);

Description

Deletes the specified object.

Parameters

CBase *aPtr

Pointer to the CBase derived object to be deleted.


Extension_(TUint,TAny *&,TAny *)

protected: IMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny *&a0, TAny *a1);

Description

Extension function

Parameters

TUint aExtensionId

TAny *&a0

TAny *a1

Return value

TInt