CHP 2 - Basic Elements of C++
CHP 2 - Basic Elements of C++
? ? ? ?
Figure 2-2 Memory allocation after the four variable declaration statements
? ? ?
Figure 2-3 Memory spaces after the statement length = 6.0; executes
• For example:
#include <iostream>
– Causes the preprocessor to include the header file
iostream in the program. Without this, you could not
use cout or cin in your program.
C++ Programming: From Problem Analysis to Program Design, Seventh Edition 63
namespace and Using cin and cout in
a Program
• cin and cout are declared in the header file
iostream, but within the std namespace.
• To use cin or cout in a program, use the following
two statements:
#include <iostream>
using namespace std;
• Without that using statement, you would need to
type std::cin instead of cin throughout your
program.