0% found this document useful (0 votes)
67 views

C++ Session 1

C++ was developed in 1980 by Bjarne Stroustrup at Bell Labs as a superset of C that added object-oriented programming capabilities. It supports features like inheritance, polymorphism, encapsulation, and abstraction. C++ is a middle-level language that supports both high-level and low-level programming. It is used to develop applications like Windows systems, databases, and more. C++ differs from C in that it is object-oriented, supports concepts like classes and objects, and includes additional features like function overloading, overriding, references, and exceptions.

Uploaded by

Arun Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

C++ Session 1

C++ was developed in 1980 by Bjarne Stroustrup at Bell Labs as a superset of C that added object-oriented programming capabilities. It supports features like inheritance, polymorphism, encapsulation, and abstraction. C++ is a middle-level language that supports both high-level and low-level programming. It is used to develop applications like Windows systems, databases, and more. C++ differs from C in that it is object-oriented, supports concepts like classes and objects, and includes additional features like function overloading, overriding, references, and exceptions.

Uploaded by

Arun Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

C++ Session 01 Document

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.

C++ programming language was developed in 1980 by Bjarne Stroustrup at bell


laboratories of AT&T (American Telephone & Telegraph), located in U.S.A.

Bjarne Stroustrup is known as the founder of C++ language.

It was develop for adding a feature of OOP (Object Oriented Programming) in C


without significantly changing the C component.

C++ programming is "relative" (called a superset) of C, it means any valid C program is


also a valid C++ program.

Let's see the programming languages that were developed before C++ language.

Language Year Developed By

Algol 1960 International Group

BCPL 1967 Martin Richard

B 1970 Ken Thompson

Traditional 1972 Dennis Ritchie


C

K&RC 1978 Kernighan & Dennis Ritchie

C++ 1980 Bjarne Stroustrup

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.

Object-Oriented Programming (OOPs)

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

C++ Standard Libraries

Standard C++ programming is divided into three important parts:

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 a structural or procedural oriented programming language which is machine-


independent and extensively used in various applications.

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++?

C++ is a special-purpose programming language developed by Bjarne Stroustrup at


Bell Labs circa 1980. C++ language is very similar to C language, and it is so compatible
with C that it can run 99% of C programs without changing any source of code though
C++ is an object-oriented programming language, so it is safer and well-structured
programming language than C.

Let's understand the differences between C and 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.

Let's summarize the above differences in a tabular form.

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.

3) C follows the top-down approach. C++ follows the bottom-up approach.

4) C does not support function C++ supports function overloading.


overloading.

5) In C, you can't use functions in In C++, you can use functions in


structure. structure.

6) C does not support reference C++ supports reference variables.


variables.

7) In C, scanf() and printf() are C++ mainly uses stream cin and


mainly used for input/output. cout to perform input and output
operations.

8) Operator overloading is not Operator overloading is possible in C+


possible in C. +.

9) C programs are divided C++ programs are divided


into procedures and modules into functions and classes.

10 C does not provide the feature of C++ supports the feature of namespace.
) namespace.

11 Exception handling is not easy in C++ provides exception handling using


) C. It has to perform using other Try and Catch block.
functions.

12 C does not support the inheritance. C++ supports inheritance.


)

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.

3) Mid-level programming language

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.

4) Structured programming 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

The compilation and execution time of C++ language is fast.

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

C++ language is extensible because it can easily adopt new features.

Page 10 of 12
11) Object Oriented

C++ is object oriented programming language. OOPs makes development and


maintenance easier where as in Procedure-oriented programming language it is not
easy to manage if code grows as project size grows.

12) Compiler based

C++ is a compiler based programming language, it means without compilation no C++


program can be executed. First we need to compile our program using compiler and
then we can execute our program.

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

You might also like