August 2001
Beginner
482 pages
10h 52m
English
There are two ways to define an integer variable. You can define the variable and then assign a value to it later in the program. For example:
int Weight; // define a variable ... // other code here Weight = 7; // assign it a value
Or you can define the integer and immediately initialize it. For example:
int Weight = 7; // define and initialize to 7
Initialization combines the definition of the variable with its initial assignment. Nothing stops you from changing that value later. Initialization ensures that your variable is never without a meaningful value.
How do you initialize the member data of a class? Classes have a special member function called a constructor that is called when an object of the class is ...
Read now
Unlock full access