C++
Primitive Data Types
Primitive data types are data structures built into the C++ language. They include basic numeric data, such as integers and floating point numbers, as well as character and Boolean variables.
-
Primitive data types:
-
void: generic identifier that does not imply type
-
int: basic integer variable; 2 or 4 bytes
-
float: basic floating point variable; 4 bytes
-
double: double precision floating point variable; 8 bytes
-
char: basic ASCII character variable; 1 byte
-
bool: basic Boolean variable; 1 byte
-
-
Modifiers: All modifiers default to int if a base type is not specified.
-
unsigned: does not use a sign bit
-
long: may have double number of bytes as base type; implementation dependent
-
short: may have half the number of bytes as base type; implementation dependent
-
-
Arrays: Arrays are blocks of consecutive data structures. Arrays are declared with a specific size in the following way:
int a[size];
A specific part of an array is referenced using an index, which is an integer value from 0 to size - 1.
-
Enumeration: A data type that holds a set of values defined by the user. An enumeration can be named, and if so, the name is also the type. Members of an enumeration are integral types that have values associated with them. The user declares the values in a list enclosed by brackets:
enum cards {CCLUBS, DIAMONDS, HEARTS, SPADES}
The enumeration type is cards, and the integral types are assigned to the enumerator values as follows:
0 = = CLUBS, 1 = = DIAMONDS, 2 = = HEARTS, 3 = = SPADES
Primitive Data Types

