SlideShare a Scribd company logo
1 of 18
PRESENTATION
ON C++
PRESENTED BY :
PRIYANSHU JAIN
(PIET18CS111)
INTRODUCTION TO C++
 C++ Is Developed by Bjarne stroustrup in 1979 at Bell labs.
All the programs written in c language can be run in all c++
compilers.
C++ IS AN EXTENSION OR ADVANCE VERSION OF C
LANGAUGE.
C++ IS BASED ON OOPs (OBJECT ORIENTED
PROGRAMMING).
HEADER FILE DECLARATION
GLOBAL DECLARATION
CLASS DECLARATION
AND
METHOD DECLARATION SECTION
MAIN FUNCTION
METHOD DEFINITION SECTION
INPUT OUTPUT STREAMS IN C++
In c++, input and output are performed using stream. If you
want to output something, you put it into an output stream,
and when you want something to be input , you get it from an
input stream. The standard output and input streams in c++ are
called cout and cin and they use your computer‘s screen and
keyboard respectively . The code above outputs the character
string ― The best place to start is at the beginning‖ to your
screen by placing it in the output stream with insertion
operator <<, when we come to write programs that involve
input using the extraction operator >>.
The name cout is defined in the header file iostream.h . This is
a standard header file that provides the definition necessary for
you to use the standard input and output facilities in c++.
#include<iostream>
using namespace std;
int main()
{
int a;
cout<<“enter value of a”;
cin>>a;
cout<<“value of a=“<<a;
return 0;
}
 It is a way of combining data and functions into an independent entity called
class. A class is like a blueprint of object.
 A class is a user defined datatype which has data members and member functions
used to access the data members.
DECLARATION OF CLASSES
 A class can be defined by the keyword class. The format of class declaration is given
below:
Class class_name
{
private:
variable declarations
function declarations
public :
variable declarations
function declarations
};
 The variables and functions declared in a class under keyword
private are not accessible to any outside function. This feature
of class declaration is called data hiding.
 Access specifiers :
 The keywords private and public are called access specifiers. In
the absence of a specifier , all declaration defined in a class by
default private.
 Member function definition :
 The member functions can be defined inside as well as outside
the class declaration. If a member function is very small then it
can be defined inside the class itself. And if a member function is
large then it can be defined outside the class.
MEMBER FUNCTION INSIDE CLASS
DECLARATION
#include<iostream>
using namespace std;
class class _name
{
public:
Void function_name()
{
statement1;
Statement 2;
----
}
MEMBER FUNCTION OUTSIDE CLASS
DECLARATION
#include<iostream>
using namespace std;
class class_name
{
public;
Void function_name();
};
void class_name :: function_name()
{
statement1;
Statement 2;
…..
}
The operator :: is known as scope resolution operator.
This is used to access member functions to their corresponding
class in following form.
Type class_name::function_name(parameter list)
{
function body
}
where :
type : is the data type of value to be returned.
class_name : is the name of the class to which the
function belongs.
function_name : is the name of the function being
declared.
parameter list : list of formal arguments.
 It is an activity of defining a new class in terms of an existing class. The
existing class is known as a base class.( i.e. super class) and the new class is
known as derived class ( ie. Sub class ) .
 In c++, a derived class can be obtained by adding some new data structures and
functions to base class. The derived class inherits the members of its base class
without the need to redefine them. The format for defining a derived class is
given below:
Class <derived class> : Visibility mode < base class>
{
..
..
};
 Where
class: is a reserved word
<derived class > : is the name of the subclass or new class being derived.
Visibility mode : is the mode of access to items from the base class.
The access mode is optional and can be either of the following type:
Private , public & protected
Accessible from /
Access mode
Base Class Derived class Outside
Public Yes Yes Yes
Protected Yes Yes No
Private Yes No No
 The action of visibility mode or access specifiers as follows:
The inheritances are classified in following categories:
Single inheritance
Hierarchical inheritance
Multilevel inheritance
Multiple inheritance
BASE
CLASS
SUB
CLASS
SINGLE INHERITANCE : In this the single derived class is present.
HIERARCHICAL INHERITANCE :
In hierarchical inheritance, using one super or
base class & multiple derived /sub classes.
SUPER
CLASS
OR BASE
CLASS
SUB
CLASS
SUB
CLASS
MULTILEVEL INHERITANCE
BASE
CLASS
SUB
CLASS/
BASE
CLASS
SUB
CLASS
 We know that a derived class with a single base class is said to form
single inheritance. The derived class can also become a base class for
some other derived class.
 This type of chain of deriving classes can go on as for as necessary.The
inheritance of this tupe is known as multilevel inheritance.
MULTIPLE INHERITANCE
 A class can inherit properties from more than one base class. this type of
inheritance is called as multiple inheritance. Please notice that this inheritance is
different from hierarchical inheritance wherein subclasses share the same base
class. It is also different from multilevel inheritance wherein a subclass is derived
from a class which itself is derived from another class and so on .
X Y
Z Object
Base class Base class
Derived class
or Sub Class
Constructors:
 A class constructor is a special member function of a class that is executed whenever
we create new objects of that class.
A constructor will have exact same name as the class and it does not have any return type
at all, not even void. Constructors can be very useful for setting initial values for certain
member variables.
 The constructor function can also be used by a programmer to initialize the internal data
members of the object. In C++ , there are three types of constructors:
1. The default constructor
2. Parameterized constructors
3. The copy constructor
Destructors :
 A destructor is a special member function of a class that is executed whenever an
object of it's class goes out of scope or whenever the delete expression is applied to a
pointer to the object of that class.
 A destructor will have exact same name as the class prefixed with a tilde (~) and it can
neither return a value nor can it take any parameters. Destructor can be very useful for
releasing resources before coming out of the program like closing files, releasing
memories etc.
C++ presentation

More Related Content

What's hot (20)

Introduction to c++ ppt 1
Introduction to c++ ppt 1Introduction to c++ ppt 1
Introduction to c++ ppt 1
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Introduction to c++ ppt
Introduction to c++ pptIntroduction to c++ ppt
Introduction to c++ ppt
 
Constructors and Destructor in C++
Constructors and Destructor in C++Constructors and Destructor in C++
Constructors and Destructor in C++
 
This pointer
This pointerThis pointer
This pointer
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Structure in C
Structure in CStructure in C
Structure in C
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Data types in C
Data types in CData types in C
Data types in C
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
structure and union
structure and unionstructure and union
structure and union
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++
 

Similar to C++ presentation

Similar to C++ presentation (20)

Opp concept in c++
Opp concept in c++Opp concept in c++
Opp concept in c++
 
Ppt of c++ vs c#
Ppt of c++ vs c#Ppt of c++ vs c#
Ppt of c++ vs c#
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.ppt
 
Class objects oopm
Class objects oopmClass objects oopm
Class objects oopm
 
Class and object in C++ By Pawan Thakur
Class and object in C++ By Pawan ThakurClass and object in C++ By Pawan Thakur
Class and object in C++ By Pawan Thakur
 
Inheritance
InheritanceInheritance
Inheritance
 
C++ Notes
C++ NotesC++ Notes
C++ Notes
 
OOPs & C++ UNIT 3
OOPs & C++ UNIT 3OOPs & C++ UNIT 3
OOPs & C++ UNIT 3
 
Introduction to object oriented programming concepts
Introduction to object oriented programming conceptsIntroduction to object oriented programming concepts
Introduction to object oriented programming concepts
 
6 Inheritance
6 Inheritance6 Inheritance
6 Inheritance
 
OOP
OOPOOP
OOP
 
Lecturespecial
LecturespecialLecturespecial
Lecturespecial
 
Access controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modesAccess controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modes
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
Inheritance Inheritance
Inheritance
 
Ganesh groups
Ganesh groupsGanesh groups
Ganesh groups
 
inheritance
inheritanceinheritance
inheritance
 
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCECLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
 
Inheritance
InheritanceInheritance
Inheritance
 

Recently uploaded

Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 

Recently uploaded (20)

Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 

C++ presentation

  • 1. PRESENTATION ON C++ PRESENTED BY : PRIYANSHU JAIN (PIET18CS111)
  • 2. INTRODUCTION TO C++  C++ Is Developed by Bjarne stroustrup in 1979 at Bell labs. All the programs written in c language can be run in all c++ compilers. C++ IS AN EXTENSION OR ADVANCE VERSION OF C LANGAUGE. C++ IS BASED ON OOPs (OBJECT ORIENTED PROGRAMMING).
  • 3. HEADER FILE DECLARATION GLOBAL DECLARATION CLASS DECLARATION AND METHOD DECLARATION SECTION MAIN FUNCTION METHOD DEFINITION SECTION
  • 4. INPUT OUTPUT STREAMS IN C++ In c++, input and output are performed using stream. If you want to output something, you put it into an output stream, and when you want something to be input , you get it from an input stream. The standard output and input streams in c++ are called cout and cin and they use your computer‘s screen and keyboard respectively . The code above outputs the character string ― The best place to start is at the beginning‖ to your screen by placing it in the output stream with insertion operator <<, when we come to write programs that involve input using the extraction operator >>. The name cout is defined in the header file iostream.h . This is a standard header file that provides the definition necessary for you to use the standard input and output facilities in c++.
  • 5. #include<iostream> using namespace std; int main() { int a; cout<<“enter value of a”; cin>>a; cout<<“value of a=“<<a; return 0; }
  • 6.  It is a way of combining data and functions into an independent entity called class. A class is like a blueprint of object.  A class is a user defined datatype which has data members and member functions used to access the data members. DECLARATION OF CLASSES  A class can be defined by the keyword class. The format of class declaration is given below: Class class_name { private: variable declarations function declarations public : variable declarations function declarations };
  • 7.  The variables and functions declared in a class under keyword private are not accessible to any outside function. This feature of class declaration is called data hiding.  Access specifiers :  The keywords private and public are called access specifiers. In the absence of a specifier , all declaration defined in a class by default private.  Member function definition :  The member functions can be defined inside as well as outside the class declaration. If a member function is very small then it can be defined inside the class itself. And if a member function is large then it can be defined outside the class.
  • 8. MEMBER FUNCTION INSIDE CLASS DECLARATION #include<iostream> using namespace std; class class _name { public: Void function_name() { statement1; Statement 2; ---- }
  • 9. MEMBER FUNCTION OUTSIDE CLASS DECLARATION #include<iostream> using namespace std; class class_name { public; Void function_name(); }; void class_name :: function_name() { statement1; Statement 2; ….. }
  • 10. The operator :: is known as scope resolution operator. This is used to access member functions to their corresponding class in following form. Type class_name::function_name(parameter list) { function body } where : type : is the data type of value to be returned. class_name : is the name of the class to which the function belongs. function_name : is the name of the function being declared. parameter list : list of formal arguments.
  • 11.  It is an activity of defining a new class in terms of an existing class. The existing class is known as a base class.( i.e. super class) and the new class is known as derived class ( ie. Sub class ) .  In c++, a derived class can be obtained by adding some new data structures and functions to base class. The derived class inherits the members of its base class without the need to redefine them. The format for defining a derived class is given below: Class <derived class> : Visibility mode < base class> { .. .. };  Where class: is a reserved word <derived class > : is the name of the subclass or new class being derived. Visibility mode : is the mode of access to items from the base class. The access mode is optional and can be either of the following type: Private , public & protected
  • 12. Accessible from / Access mode Base Class Derived class Outside Public Yes Yes Yes Protected Yes Yes No Private Yes No No  The action of visibility mode or access specifiers as follows:
  • 13. The inheritances are classified in following categories: Single inheritance Hierarchical inheritance Multilevel inheritance Multiple inheritance BASE CLASS SUB CLASS SINGLE INHERITANCE : In this the single derived class is present.
  • 14. HIERARCHICAL INHERITANCE : In hierarchical inheritance, using one super or base class & multiple derived /sub classes. SUPER CLASS OR BASE CLASS SUB CLASS SUB CLASS
  • 15. MULTILEVEL INHERITANCE BASE CLASS SUB CLASS/ BASE CLASS SUB CLASS  We know that a derived class with a single base class is said to form single inheritance. The derived class can also become a base class for some other derived class.  This type of chain of deriving classes can go on as for as necessary.The inheritance of this tupe is known as multilevel inheritance.
  • 16. MULTIPLE INHERITANCE  A class can inherit properties from more than one base class. this type of inheritance is called as multiple inheritance. Please notice that this inheritance is different from hierarchical inheritance wherein subclasses share the same base class. It is also different from multilevel inheritance wherein a subclass is derived from a class which itself is derived from another class and so on . X Y Z Object Base class Base class Derived class or Sub Class
  • 17. Constructors:  A class constructor is a special member function of a class that is executed whenever we create new objects of that class. A constructor will have exact same name as the class and it does not have any return type at all, not even void. Constructors can be very useful for setting initial values for certain member variables.  The constructor function can also be used by a programmer to initialize the internal data members of the object. In C++ , there are three types of constructors: 1. The default constructor 2. Parameterized constructors 3. The copy constructor Destructors :  A destructor is a special member function of a class that is executed whenever an object of it's class goes out of scope or whenever the delete expression is applied to a pointer to the object of that class.  A destructor will have exact same name as the class prefixed with a tilde (~) and it can neither return a value nor can it take any parameters. Destructor can be very useful for releasing resources before coming out of the program like closing files, releasing memories etc.