C++: Fundamental Data Types

Fundamental Data Types

This C++ video tutorial covers the data types that are built into the language. In later lessons, we will show how programmers can use these to build their own data types. However, is essential to fully understand these simple data types first. Here is a table of the available data types:

Even though there are many types built into C++, we can get by with using fairly few of them. In fact, the types inside of each of the boxes above are all redundant. Much the reason for this redundancy comes from the fact that C++ grown out of C and therefore carries many of the legacy issues of C. We can strip the full list of types above down a single representative type from each class: these are the most commonly used variants:

Even with the pared down list of data types, we will find that we need only a small subset of these for almost all applications. However, you should be aware of the full list of C++ data types, since you may find yourself looking at legacy code. The main data types in C++ are the four that were given as the basic data types: char, int, double, and bool. Aside from these you should know how void is used and be familiar with the unsigned types, particularly the unsigned int.

As UNICODE replaces ASCII for defining alphanumeric characters and applications become more global, wchar_t is becoming more important. However, you can expect that the char code will persist for a long time. So, become familiar with the ASCII table; it is not going away anytime soon.

Above is a list of data types along with the value range that they can represent. Historically, programmers used smaller data types to save on memory. Nowadays, memory is plentiful is only a mildly significant issue in large data sets like images, videos, etc. Memory is still an issue in computing code optimization, but sometimes a larger data type may actually be faster—it can be difficult to tell and we will get into that in later lessons. Memory, architecture and optimization all go together and the issues get very complex, particularly as computers become more sophisticated.