Professional Documents
Culture Documents
PF - Week 4 Lecture
PF - Week 4 Lecture
Fundamentals
1
C++ DATA TYPES- REVISITED
Data types
Boolean
Numeric Character
bool
allDone finished
1 0
4
Character Strings
H e l l o \0
5
THE C++ STRING CLASS
•
Special data type supports working with strings
#include <string>
•
Can define string variables in programs:
string firstName, lastName;
•
Can receive values with assignment operator:
firstName = "George";
lastName = "Washington";
•
Can be displayed via cout
cout << firstName << " " << lastName;
6
THE STRING CLASS IN PROGRAM
7
THE PARTS OF A C++ PROGRAM
C++ programs have parts and components that serve specific purpose
10
FORMATTING OUTPUT
The cout object provides ways to format data as it
is being displayed.
This affects the way data appears on the screen
Continued…
MORE STREAM MANIPULATORS IN
PROGRAM 3-17
STREAM MANIPULATOR
Stream manipulator functions with cout can control how
output displays for numeric, string data: