There are more primitive data types in
C+ which are variation on the ones
described above. They are as follows:
unsigned char - takes nonnegative values twice as high as
unsigned int - similarly, takes
on non-negative values up to twice
The third line is one which appears in every program. It
introduces the main() function, which is where your
programs will always begin to execute instructions. The
main() function is often of return type void. More on
this topic later. For now, just acce
An important feature of object-oriented programming languages is inheritance:
the ability to create derived classes. Consider the following class denition:
int get_num_sides() cfw_return num_sides;
Problem : Why are there different data types?
Different data types are used for different types of values.
If you are trying to represent something with discrete
values (i.e. something you might count), integers are
usually useful. If the numbers require
#include - The #include command tells the compiler to
use the specied header le as part of your program.
Header File - A le ending in .h which contains
denitions of variables, classes, and functions that may be
useful in your code.
Syntax - The usage of a
Here is a rst example of a C+
program, one which virtually every C+
+ programmer learns when starting off:
/ So we can use the
cout < "Hello World!
\n"; /* this is pretty
This program does a
Problem : What is the purpose of the #include statement in
a C+ program?
The #include statement tells the C+ preprocessor to
insert the denitions of variables, classes, and functions
into the current le. #include <iostream.h>, for
example, lets you use th
Programming is essentially the manipulation of many
variables. The basic variable data types which C+
variables can assume are: int (integers), char
(characters) and doubles (real decimals). Declaring a
variable simply means letting the computer know that
Problem : Why should you use classes?
Classes are a great way of packaging data and
functionality in units that can be easily manipulated.
Classes provide structure to C+ programs. If your
program does not have classes, you might as well use
C+ is a computer programming language that supports object-oriented
programming, meaning it is largely concerned with the manipulation of
special variables called objects. Classes are used to create objects, but before
learning about them it is essential