Type Categories

From RAD Studio
Jump to: navigation, search

Go Up to Declaration Syntax Index

Provides information on C++ type categories.

The four basic type categories (and their subcategories) are as follows:

   class (C++ only)
   Reference (C++ only)

Types can also be viewed in another way: they can be fundamental or derived types. The fundamental types are void, char, int, float, and double, together with short, long, signed, and unsigned variants of some of these. The derived types include pointers and references to other types, arrays of other types, function types, class types, structures, and unions.

A class object, for example, can hold a number of objects of different types together with functions for manipulating these objects, plus a mechanism to control access and inheritance from other classes.

Given any nonvoid type type (with some provisos), you can declare derived types as follows:

Declaring Types:

Declaration Description

type t;

An object of type type

type array[10];

Ten types: array[0] - array[9]

type *ptr;

ptr is a pointer to type

type &ref = t;

ref is a reference to type (C++)

type func(void);

func returns value of type type

void func1(type t);

func1 takes a type type parameter

struct st {type t1;type t2};

structure st holds two types

Note: type& var, type &var, and type & var are all equivalent.

See Also