Sams Teach Yourself C in 21 Days

(singke) #1
an int: 123
a long: 987654321
a float: 123.456
a char: A
a string: A String
a bool: 1
A number of different data types are used to declare a number of variables in
lines 6–11. In lines 14–19, you see coutbeing used with each of these variables
being redirected. As you can see by the output, all are printed.

652 Bonus Day 2

OUTPUT

ANALYSIS

coutrequires that the iostream.h header file be included.
Note

Understanding the C++ Keywords ....................................................................


All the keywords within the C programming language work in C++. Remember, C++ is
a superset of C. Everything in a C program will work in a C++ program. This does not,
however, mean that you should use everything you can in a C program in your C++ pro-
grams!
In addition to the C keywords, C++ adds several additional keywords. A list of the com-
monly used ANSI standard C++ keywords is presented in the list which follows. Note
that the C++ keywords that are not considered a part of C are in bold text. As you can
see, all the familiar C keywords are available. Additionally, the functionality of the C
keywords is exactly what you have already learned!
Some of the common C++ keywords
break case catch class
const continue delete do
double else float for
goto if inline int
long namespace new operator
private protected public static
struct switch throw try
union void while

Words in bold are ANSI C++ keywords not a part of the ANSI C language.
Note

37 448201x-Bonus2 8/13/02 11:18 AM Page 652

Free download pdf