C++ Session 1
C++ Session 1
Page 1 of 12
Topics Covered
History of C++ 3 To 3
Introduction of C++ 4 To 5
C vs. C++ 5 To 8
C++ Features 9 To 11
Advantages of C++ 11 To 11
Page 2 of 12
C++ history
History of C++ language is interesting to know. Here we are going to discuss brief
history of C++ language.
Let's see the programming languages that were developed before C++ language.
Page 3 of 12
Introduction of C++
C++ is a general purpose, case-sensitive, free-form programming language that
supports object-oriented, procedural and generic programming.
C++ is a middle-level language, as it encapsulates both high and low level language
features.
C++ supports the object-oriented programming, the four major pillar of object-oriented
programming (OOPs) used in C++ are:
1. Inheritance
2. Polymorphism
3. Encapsulation
4. Abstraction
o The core library includes the data types, variables and literals, etc.
o The standard library includes the set of functions manipulating strings, files, etc.
o The Standard Template Library (STL) includes the set of methods manipulating a
data structure.
Usage of C++
By the help of C++ programming language, we can develop different types of secured
and robust applications:
o Window application
o Client-Server application
o Device drivers
o Embedded firmware etc
Page 4 of 12
C++ Program
In this tutorial, all C++ programs are given with C++ compiler so that you can easily
change the C++ program code.
File: main.cpp
1. #include <iostream>
2. using namespace std;
3. int main() {
4. cout << "Hello C++ Programming";
5. return 0;
6. }
C vs. C++
What is C?
C is the basic programming language that can be used to develop from the operating
systems (like Windows) to complex programs like Oracle database, Git, Python
interpreter, and many more. C programming language can be called a god's
programming language as it forms the base for other programming languages. If we
know the C language, then we can easily learn other programming languages. C
language was developed by the great computer scientist Dennis Ritchie at the Bell
Laboratories. It contains some additional features that make it unique from other
programming languages.
What is C++?
Page 5 of 12
The following are the differences between C and C++:
o Definition
C is a structural programming language, and it does not support classes and
objects, while C++ is an object-oriented programming language that supports the
concept of classes and objects.
o Type of programming language
C supports the structural programming language where the code is checked line
by line, while C++ is an object-oriented programming language that supports the
concept of classes and objects.
o Developer of the language
Dennis Ritchie developed C language at Bell Laboratories while Bjarne
Stroustrup developed the C++ language at Bell Labs circa 1980.
o Subset
C++ is a superset of C programming language. C++ can run 99% of C code but C
language cannot run C++ code.
o Type of approach
C follows the top-down approach, while C++ follows the bottom-up approach.
The top-down approach breaks the main modules into tasks; these tasks are
broken into sub-tasks, and so on. The bottom-down approach develops the lower
level modules first and then the next level modules.
o Security
In C, the data can be easily manipulated by the outsiders as it does not support
the encapsulation and information hiding while C++ is a very secure language,
i.e., no outsiders can manipulate its data as it supports both encapsulation and
data hiding. In C language, functions and data are the free entities, and in C++
language, all the functions and data are encapsulated in the form of objects.
o Function Overloading
Function overloading is a feature that allows you to have more than one function
Page 6 of 12
with the same name but varies in the parameters. C does not support the
function overloading, while C++ supports the function overloading.
o Function Overriding
Function overriding is a feature that provides the specific implementation to the
function, which is already defined in the base class. C does not support the
function overriding, while C++ supports the function overriding.
o Reference variables
C does not support the reference variables, while C++ supports the reference
variables.
o Keywords
C contains 32 keywords, and C++ supports 52 keywords.
o Namespace feature
A namespace is a feature that groups the entities like classes, objects, and
functions under some specific name. C does not contain the namespace feature,
while C++ supports the namespace feature that avoids the name collisions.
o Exception handling
C does not provide direct support to the exception handling; it needs to use
functions that support exception handling. C++ provides direct support to
exception handling by using a try-catch block.
o Input/Output functions
In C, scanf and printf functions are used for input and output operations,
respectively, while in C++, cin and cout are used for input and output
operations, respectively.
o Memory allocation and de-allocation
C supports calloc() and malloc() functions for the memory allocation, and free()
function for the memory de-allocation. C++ supports a new operator for the
memory allocation and delete operator for the memory de-allocation.
o Inheritance
Inheritance is a feature that allows the child class to reuse the properties of the
parent class. C language does not support the inheritance while C++ supports
the inheritance.
o Header file
C program uses <stdio.h> header file while C++ program
uses <iostream.h> header file.
No. C C++
Page 7 of 12
1) C follows the procedural style C++ is multi-paradigm. It supports
programming. both procedural and object oriented.
2) Data is less secured in C. In C++, you can use modifiers for class
members to make it inaccessible for
outside users.
10 C does not provide the feature of C++ supports the feature of namespace.
) namespace.
C++ Features
C++ is object oriented programming language. It provides a lot of features that are
given below.
Page 8 of 12
1. Simple
2. Machine Independent or Portable
3. Mid-level programming language
4. Structured programming language
5. Rich Library
6. Memory Management
7. Fast Speed
8. Pointers
9. Recursion
10. Extensible
11. Object Oriented
12. Compiler based
1) Simple
C++ is a simple language in the sense that it provides structured approach (to break the
problem into parts), rich set of library functions, data types etc.
Page 9 of 12
2) Machine Independent or Portable
Unlike assembly language, c programs can be executed in many machines with little bit
or no change. But it is not platform-independent.
C++ is also used to do low level programming. It is used to develop system applications
such as kernel, driver etc. It also supports the feature of high level language. That is
why it is known as mid-level language.
C++ is a structured programming language in the sense that we can break the program
into parts using functions. So, it is easy to understand and modify.
5) Rich Library
C++ provides a lot of inbuilt functions that makes the development fast.
6) Memory Management
It supports the feature of dynamic memory allocation. In C++ language, we can free the
allocated memory at any time by calling the free() function.
7) Speed
8) Pointer
C++ provides the feature of pointers. We can directly interact with the memory by
using the pointers. We can use pointers for memory, structures, functions, array etc.
9) Recursion
In C++, we can call the function within the function. It provides code reusability for
every function.
10) Extensible
Page 10 of 12
11) Object Oriented
Advantages of C++
C++ doesn't only maintains all aspects from C language, it also simplifies memory
management and adds several features like:
C++ is a highly portable language means that the software developed using C++
language can run on any platform.
C++ is an object-oriented programming language which includes the concepts
such as classes, objects, inheritance, polymorphism, abstraction.
C++ has the concept of inheritance. Through inheritance, one can eliminate the
redundant code and can reuse the existing classes.
Data hiding helps the programmer to build secure programs so that the program
cannot be attacked by the invaders.
Message passing is a technique used for communication between the objects.
C++ contains a rich function library.
SESSION : I
1) What is C++?
2) What are the standard libraries of C++?
3) What is the usage of C++?
4) What is the difference between C & C++?
5) What are the features of C++?
6) What are the advantages of C++?
Page 11 of 12
Page 12 of 12