![]() |
|
|
Understanding the Different Types of Variables/
Learn the Basics
Data
Types (variables)
The
Terminology
Declaring
Data Types and Using the Various Operators
Rules
for Naming Data Types
C++
Libraries
Data Types (variables) When you start learning any programming language, it is essential that you familiarize yourself with the different types of variables for that language. Variables are simply containers that hold numbers or characters in memory. The name 'variable' means that the values in these "containers" can be changed at any time. Variables make it extremely easy for you to pass information from one control to another in your program. For example, if you want to determine if a user can drive a car legally or not, you could obtain their age from them, pass it on to another function that does the calculation and then display the result. Here are the main types of data types:
When a data type from the table above is preceded by the keyword const, then that tells the compiler (the program you are writing your C++ program in) that this certain variable will not change throughout the application. Making certain variables constants is considered a good thing, since it gives the compiler more chance to find your mistakes for you, as well as making your code more easier to maintain and update later on. |