Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Using TFixedArray

To declare an array of four TTest type objects, use:

TFixedArray<TTest,4> array;

This replaces the more usual declaration:

TTest array[4];

The array can be initialised either at construction time or by using the TFixedArray<class T,TInt S>::Copy() member function after construction.

...
const TTest data[] = {TTest(1),TTest(2),TTest(3),TTest(4)};
...
TFixedArray<TTest,4> array(&data[0],4); // initialise at construction
... // time
...
array.Copy(&data[0],4);

Accesses to the array can be checked for legality using the At() function or the operator[].The At() function checks for a legal access in both a release build and a debug build while the operator[] just checks for legal access in a debug build.

array.At(1); // is legal and returns a reference to the
                   // second TTest element.
...
array.At(4); // raises a panic; it attempts to access the 5th
                   // TTest element; the are only four elements