November 2001
Beginner
1128 pages
29h 12m
English
A C++ program is a collection of functions, and each function is a collection of statements. C++ has several kinds of statements, so let's look at some of the possibilities. Listing 2.2 provides two new kinds of statements. First, a declaration statement creates a variable. Second, an assignment statement provides a value for that variable. Also, the program shows a new capability for cout.
// fleas.cpp -- display the value of a variable
#include <iostream>
using namespace std;
int main()
{
int fleas; // create an integer variable
fleas = 38; // give a value to the variable
cout << "My cat has ";
cout << fleas; // display the value of fleas
cout << " fleas.\n";
return 0;
}
|
A blank line separates ...