#5 UBEOR
iented Programming with C++
will
Prevent a C program to run under C++ compiler. We shall see these differences later ,
and when they are encountered. A com} vet he
anc : rehensive list of major diffe fie
WANEIC+tisgiveninAppendizA, piel mat chen eee ANS ¢
(The most important facilities that C++ adds on to C are classes, inheritance, function
overloading, and operator overloading. These features enable creating of abstract data types
inherit properties from existing data types and support polymorphism, thereby making C+, ,
truly object-oriented language. |
¥ (the object-oriented features in C++ allow programmers to build large programs with
clarity, extensibility and ease of maintenancé)incorporating the spirit and efficiency of C
The addition of new features has transformed C from a language that currently facilitate
top-down, structured design, to one that provides bottom-up, object-oriented design.
C++ is a versatile language for handling very large programs. It is suitable for virtually any
programming task including development of editors, compilers, databases, communication
systems and any complex real-life application systems.
@ Since C++ allows us to create hierarchy-related objects, we can buildspecial object-
oriented libraries which can be used later by many programmers.
© While C++ is able to map the real-world problem properly, the C part of C++ gives
the language the ability to get close to the machine-level details.
© C++ programs are easily maintainable and expandable. When a new feature need:
to be implemented, it is very easy to add to the existing structure of an object,
© It is expected that C++ will replace C as a general-purpose language in the near future.
+ Letus begin with a simple example of a C++ program that prints a string on the screen.
demonstrates several C++features.it the default return
and return will run.
type for all functions i i
ee eS C++ is int. The following main
sider a slightly more complex C++ program. Assume that we would like to read two
‘the keyboard and display their average on the screen. C++ statements to accomplish
Program 2.2.‘M__ Object-Oriented Programming with C++
3.4 IDENTIFIERS AND CONSTANTS
i Jasses, etc. created by t,
i er to the names of variables, functions, arrays,