AllTheTimeWorld.com

csharp variablesC++ Variables: type

C++ Variables: type

C++ Variables: type

Before a variable can be used, it must be declared. To declare a variable, first decide what type of information you want to store.

Basic Types

Whole numbers, number with no decimal places are called int (integers.)
Numbers with decimal places and very large numbers are called double.
Single letters such as ‘Y’ or ‘N’ are char (characters.)
Words, such as “Hello”, or a persons name are called strings.
Variables that can only have the values true or false are called bool (Boolean.)
Strings are somewhat more complicated because they require an array of memory locations. Strings are discussed in another lesson.

In addition to the primitive types, variables can also be declared as one of the classes:
// This will make the background of the form blue.
Color myFav = Color.Blue;
BackColor = myFav;


Drill on type