Data Types in C++ – Detailed instructions from [A-Z]

The type of data that a variable can retain is defined by its data type; for instance, an integer variable can hold only integer data, a character type variable can only hold character data, etc.

In C++, data types are divided into three categories: built-in, user-defined, and derived.

Built in data types

char: For characters. Size 1 byte.

char ch = 'A';

int: For integers. Size 2 bytes.

int num = 100;

float: For single precision floating point. Size 4 bytes.

float num = 123.78987;

double: For double precision floating point. Size 8 bytes.

double num = 10098.98899;

bool: For booleans, true or false.

bool b = true;

wchar_t: Wide Character. This should be avoided because its size is implementation defined and not reliable.

User-defined data types

We have three types of user-defined data types in C++
1. struct
2. union
3. enum

In separate tutorials, I went over each in great detail. Just keep in mind that these fall under user-defined data types for the time being.

C++ derived data types

In C++, there are three different forms of derived data types.

1. Array
2. Function
3. Pointer

These are extensive C++ subjects that I have addressed in separate tutorials. To succeed, simply follow the instructions in the order they are presented.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button