Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

T class

From Wiki
Jump to: navigation, search
Article Metadata
Created: vin2ktalks (20 Mar 2007)
Last edited: hamishwillee (26 Jul 2012)

This article provides a very brief overview of Symbian T classes. See An Introduction to T Classes for a more comprehensive introduction.

Simple type class. T classes typically have no explicit constructor and never have a destructor. They can be allocated on the stack or heap.

T classes are generally used to encapsulate integers, booleans and simple other types, or as enumerations:

TDayOfWeek weekday; // An enumeration 
TBool doContinue = ETrue; // A boolean value
TPoint origin; // A point object having TInt X and TInt Y member variables


  • A T classes does not have a destructor as you cannot ensure that it is called in the event of a Leave.
  • As a result, a T class must not own any object that requires cleanup (such as a heap-based C class object or pointer to memory on the heap, or an R class object). It is acceptable (but rare) for a T class to hold a reference to such an object owned, and cleaned up, elsewhere.
  • T class objects like the built-in types, they are returned by value, and may be passed by reference or value.
  • Member variables are not automatically zero-initialized like in C classes.
  • T classes are typically small in size, thus they're usually created on stack.
  • T classes do not have a destructor,they act like built-in types. That’s why the typedefs for all built-in types begin with T. T classes can be allocated automatically (if they’re not too big), as members of other classes or on the heap.
  • Only Symbian OS T-class objects can safely be put onto the program stack. These include built-in types and classes that don’t need a destructor because they own no external data. This means that they can be safely discarded, without the need for any kind of cleanup, simply by exiting from the function in which the automatic variable was declared.

See also

This page was last modified on 26 July 2012, at 04:11.
42 page views in the last 30 days.