CHAPTER OUTLINE
CHAPTER TWOINTRODUCTION TO C++
-2 HOURS
2.1 The Need of C++
2.2 Features of C++
2.3 C++ Versus C
2.4 History of C++
The need of C++
C++ is a highly portable language and is often the language of selection
for multi-device, multi-platform app development.
C++ is an object-oriented programming language and includes concepts
like classes, inheritance, polymorphism, data abstraction, and
encapsulation which allow code reusability and makes programs very
maintainable.
C++ use multi-paradigm programming. The Paradigm means the style of
programming .paradigm concerned about logics, structure, and procedure
of the program. C++ is multi-paradigm means it follows three paradigm
Generic, Imperative, Object Oriented.
It is useful for the low-level programming and very efficient for general
purpose.
C++ gives the user complete control over memory management. This can
be seen both as an advantage and a disadvantage as this increases the
responsibility of the user to manage memory rather than it being managed
by the Garbage collector.
4
Contd...
The wide range of applications: From GUI applications to 3D graphics for
games to real-time mathematical simulations, C++ is everywhere.
C++ has a huge community around it. Community size is important,
because the larger a programming language community is, the more
support you would be likely to get. C++ is the 6th most used and followed
tag on StackOverflow and GitHub.
C++ has a very big job market as it is used in various industries like
finance, app development, game development, Virtual reality, etc.
C++'s greatest strength is how scalable it could be, so apps that are very
resource intensive are usually built with it. As a statically written language,
C++ is usually more performant than the dynamically written languages
because the code is type-checked before it is executed.
Compatibility with C: C++ is compatible with C and virtually every valid
C program is a valid C++ program.
5
Features of C++
Following are the features of C++:
Namespace
Inheritance
Polymorphism
Template and Standard Template Library
Exception Handling
Simple
Portability
Powerful
Platform dependent
Case sensitive
Compiler based
Syntax based language
Use of Pointers
13 SET PIN PPP CCSU
S- simple
Exception handling last
chapter
Template and standard
template library
Polymorphism
Inheritance
Namespace
por pow pd
powerful
portability
Platform dependent
Case sensitive Compiler
based
Syntax based
Use of pointer
6
C++ Vs C
S.N. C++ C
1. C++ was developed by Bjarne
Stroustrup in 1979.
C was developed by Dennis Ritchie between
the year 1969 and 1973 at AT&T Bell Labs.
2. C++ supports polymorphism,
encapsulation, and inheritance
because it is an object oriented
programming language.
C does no support polymorphism,
encapsulation, and inheritance which means
that C does not support object oriented
programming.
3. C++ is a superset of C. C codes can
be run by C++ but C cannot run the
C++ codes.
C is a subset of C++.
4. C++ contains 52 keywords. C contains 32 keywords.
5. C++ is known as hybrid language
because C++ supports both
procedural and object oriented
programming paradigms.
For the development of code, C supports
procedural programming.
6. Data and functions are encapsulated
together in form of an object in
C++.
Data and functions are separated in C because
it is a procedural programming language.
7
7. Data is hidden by the Encapsulation
to ensure that data structures and
operators are used as intended.
C does not support information hiding.
8. Built-in & user-defined data types is
supported in C++.
Built-in data types is supported in C.
9. C++ is an object driven language
because it is an object oriented
programming.
C is a function driven language because C is
a procedural programming language.
10. Function and operator overloading is
supported by C++.
Function and operator overloading is not
supported in C.
11. C++ is an object-driven language C is a function-driven language.
12. Functions can be used inside a
structure in C++.
Functions in C are not defined inside
structures.
13. NAMESPACE is used by C++,
which avoid name collisions.
Namespace features are not present inside the
C.
Contd...
C++ C
8
14. Header file used by C++ is
iostream.h.
Header file used by C is stdio.h.
15. Reference variables are supported by
C++.
Reference variables are not supported by C.
16. Virtual and friend functions are
supported by C++.
Virtual and friend functions are not supported
by C.
17. C++ supports inheritance. C does not support inheritance.
18. C++ focuses on data instead of
focusing on method or procedure.
Instead of focusing on data, C focuses on
method or process.
19. C++ provides new operator for
memory allocation and delete
operator for memory de-allocation.
C provides malloc() and calloc()functions for
dynamic memory allocation, and free() for
memory de-allocation.
20. Exception handling is supported by
C++.
Direct support for exception handling is not
supported by C.
21. cin and cout are used for input/output
in C++.
scanf and printf functions are used for
input/output in C.
Contd...
C++ C
9
History of C++
→ C++ is an object-oriented programming language. It was developed by
Bjarne Stroustrup at AT&T Bell Laboratories in Murray Hill, New Jersey,
USA, in the early 1980’s.
→ Stroustrup, an admirer of Simula67 and a strong supporter of C, wanted to
combine the best of both the languages and create a more powerful
language that could support object-oriented programming features and
still retain the power and elegance of C. The result was C++. Therefore,
C++ is an extension of C with a major addition of the class construct
feature of Simula67.
→ Since the class was a major addition to the original C language, Stroustrup
initially called the new language ‘C with classes’. However, later in 1983,
the name was changed to C++. The idea of C++ comes from the C
increment operator ++, thereby suggesting that C++ is an augmented
version of C.
→ C+ + is a superset of C. Almost all c programs are also C++ programs.
However, there are a few minor differences that will prevent a c program
to run under C++ complier. We shall see these differences later as and
when they are encountered.
10
→ The most important facilities that C++ adds on to C care 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++ a
truly object-oriented language.
Note:
“Objective-C is a general-purpose, object-oriented programming language that adds
Smalltalk-style messaging to the C programming language.”