The C++ language contains very few built in data types these are as follows:



Boolean variable, can only be true or false. The C++ keywords true and false correspond to these values.



Character. Almost always 8 bits wide.



Wide character: used to support both Roman and Oriental languages typically 16 or 32 bits wide.



Floating point number.



Like float, but greater precision (also larger and sometimes slower, depending on the systems floating-point capability)



Integer value. Sizes vary according to system: typically 16 or 32 bits but can be larger.







Variations of the basic data types can be obtained using the following keywords:


(with int or char) value can be interpreted as positive or negative doubles and floats are inherently signed, and so do not require the signed keyword.



(with int or char value will never be interpreted as negative. Doubles and floats cannot be declared unsigned



(with int) smaller value of int (on most systems short int is a 16 bit integer)



(with int) Larger value of int (on most systems long int is a 32 bit integer)

(With double) Higher precision than double. Not always supported.

Some compilers allow a type called long long int, which is 64 bits wide (when long int is 32 bits).




If the signed or unsigned, short or long modifiers are used in a declaration statement without specifying a basic type, then int is assumed. (eg.short I; declares a short int).



The behaviour of these types can be controlled with the following keywords:



Indicates that the value of the objects is constant, and cannot be modified the compiler will report an error if a program attempts to assign a new value to a const object.



In a class definition, indicates that the particular class member may change, even when the class instance itself is declared as const. Although useful in some situations, the need to declare lots of class members as mutable can indicate a design flaw in the class.



The value of a static object will stay constant between different calls to the function in which it is declared. In this respect , static objects are like global variables, but unlike global variables, they are only visible within the scope which they were declared.



Opposite of static. An auto (automatic) object is created when it is declared, and destroyed when it goes out of scope, unless otherwise stated (by using the static keyword), all objects are interpreted as being auto.



Seldom used. A volatile item is one whose value may be changed behind the programs back. Usually only used when dealing with hardware registers.




These modifiers can be used in conjunction with each other, so it is possible to declare an object as both const and volatile, for example, the const keyword is used extensively in function declarations to prevent a function from inadvertently changing one of its arguments.

Wherever the design of a system, allows objects and function arguments should be declared as const. This can allow the compiler to perform some time and space-saving optimisations, as well as trapping potentially dangerous assignments to objects which should not be modified.