C++ Tutorial № 2 : Variables. Types. Boolean type.
Submitted by Bright777 on Saturday, February 15, 2014 - 09:04.
Hi everyone. It is Bright77 and today we are going to talk about variables: what is variable, how we should declare it and how to operate with them.
First of all we need to give a definition of term “variable”. You can say that variable it is thing that should change. It is quite right, but… So, in C++ you can imagine variable like a special container to store the information we need in the current program in the current time. Variables can store different information: from integer values to sentences and texts. As a conclusion variables can be different types.
Types of variables
The main types of variables in C++ are :
Also there is a little trick in C++ - if you declare boolean variable with non-zero int value it become "true", with zero value - "false". Code below shows it.
So, thats all for today. In the next tutorial we will talk about other types such as character type, integer types, floating-point types. If any questions - post them. See you later :)
- Boolean type
- Character type
- Integer types
- Floating-point types
- Pointer types
- Array types
- Reference types
- Data structures and classes
- bool c; //declaring variable of type bool without the value
- bool a = true; //boolean variable with value "true"
- bool x = 2; //x become "true"
- bool y = 0; //y become "false"
Add new comment
- 30 views