Intro To C++ Lesson 9
Intro To C++ Lesson 9
Intro To C++ Lesson 9
Introduction
• The object cout has a simple interface. If string represents a string variable, then the
following statement will display its contents:
cout << string;
• You may recall that the operator << is the bit-wise left-shift operator and it can still be
used for this
• purpose.
• This is an example of how one operator can be used for different purposes, depending
on the context.
• This concept is known as operator overloading, an important aspect of polymorphism.
The iostream File
• A C++ program typically contains pre-processor directive statements at the
beginning.
• All C++ programs begin with a #include directive that includes the specified
header file contents into the main program.
• We have used the following #include directive in the program:
• #include <iostream>
• This directive causes the preprocessor to add the contents of the iostream file
to the program.
• It contains declarations for the identifier cout and the operator <<.
• Some old versions of C++ use a header file called iostream.h. This is one of the
changes introduced by ANSI C++.
• (We should use iostream.h if the compiler does not support ANSI C++ features.)
• The header file iostream should be included at the beginning of all programs
that use input/output statements.
• Note that the naming conventions for header files may vary. Some
implementations use iostream.hpp; yet others iostream.hxx.
• We must include appropriate header files depending on the contents of the
program and implementation.
Namespace
• These sections may be placed in separate code files and then compiled
independently or jointly.
Visual C++
It is a Microsoft application development system for C++ that runs under Windows.
Visual C++ is a visual programming environment in which basic program components can
be selected through menu choices, buttons, icons, and other predetermined methods.
Development and execution of C++ programs under Windows are briefly explained in
Appendix C.
END OF THE LESSON