際際滷

際際滷Share a Scribd company logo
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 computers 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
Prof. Dr. K. Adisesha
Interface in java
Interface in javaInterface in java
Interface in java
PhD Research Scholar
Structure of C++ - R.D.Sivakumar
Structure of C++ - R.D.SivakumarStructure of C++ - R.D.Sivakumar
Structure of C++ - R.D.Sivakumar
Sivakumar R D .
C++
C++C++
C++
Shyam Khant
Java Data Types
Java Data TypesJava Data Types
Java Data Types
Spotle.ai
Intro to c++
Intro to c++Intro to c++
Intro to c++
temkin abdlkader
Functions in c language
Functions in c language Functions in c language
Functions in c language
tanmaymodi4
Java package
Java packageJava package
Java package
CS_GDRCST
Data types in java
Data types in javaData types in java
Data types in java
HarshitaAshwani
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
Ahmad Idrees
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
Ankur Pandey
Scope rules : local and global variables
Scope rules : local and global variablesScope rules : local and global variables
Scope rules : local and global variables
sangrampatil81
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
Sangharsh agarwal
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
Nilesh Dalvi
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
Harendra Singh
C++ programming
C++ programmingC++ programming
C++ programming
Emertxe Information Technologies Pvt Ltd
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
Nilesh Dalvi
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
fazli khaliq
Functions in C++
Functions in C++Functions in C++
Functions in C++
Mohammed Sikander
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
HalaiHansaika
Structure of C++ - R.D.Sivakumar
Structure of C++ - R.D.SivakumarStructure of C++ - R.D.Sivakumar
Structure of C++ - R.D.Sivakumar
Sivakumar R D .
Java Data Types
Java Data TypesJava Data Types
Java Data Types
Spotle.ai
Functions in c language
Functions in c language Functions in c language
Functions in c language
tanmaymodi4
Java package
Java packageJava package
Java package
CS_GDRCST
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
Ahmad Idrees
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
Ankur Pandey
Scope rules : local and global variables
Scope rules : local and global variablesScope rules : local and global variables
Scope rules : local and global variables
sangrampatil81
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
Nilesh Dalvi
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
Harendra Singh
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
Nilesh Dalvi
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
fazli khaliq
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
HalaiHansaika

Similar to C++ presentation (20)

Opp concept in c++
Opp concept in c++Opp concept in c++
Opp concept in c++
SadiqullahGhani1
Ppt of c++ vs c#
Ppt of c++ vs c#Ppt of c++ vs c#
Ppt of c++ vs c#
shubhra chauhan
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
RAJ KUMAR
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.ppt
LadallaRajKumar
Class objects oopm
Class objects oopmClass objects oopm
Class objects oopm
Shweta Shah
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
Govt. P.G. College Dharamshala
Inheritance
InheritanceInheritance
Inheritance
Burhan Ahmed
C++ Notes
C++ NotesC++ Notes
C++ Notes
MOHAMED RIYAZUDEEN
OOPs & C++ UNIT 3
OOPs & C++ UNIT 3OOPs & C++ UNIT 3
OOPs & C++ UNIT 3
Dr. SURBHI SAROHA
Introduction to object oriented programming concepts
Introduction to object oriented programming conceptsIntroduction to object oriented programming concepts
Introduction to object oriented programming concepts
Ganesh Karthik
6 Inheritance
6 Inheritance6 Inheritance
6 Inheritance
Praveen M Jigajinni
Lecturespecial
LecturespecialLecturespecial
Lecturespecial
karan saini
OOP
OOPOOP
OOP
karan saini
Access controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modesAccess controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modes
Vinay Kumar
Inheritance
InheritanceInheritance
Inheritance
Pranali Chaudhari
Inheritance
Inheritance Inheritance
Inheritance
sourav verma
Ganesh groups
Ganesh groupsGanesh groups
Ganesh groups
Ganesh Amirineni
inheritance
inheritanceinheritance
inheritance
Amir_Mukhtar
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
Venugopalavarma Raja
Inheritance
InheritanceInheritance
Inheritance
piyush shukla

Recently uploaded (20)

Carousel - Five Key FinTech Trends for 2025
Carousel - Five Key FinTech Trends for 2025Carousel - Five Key FinTech Trends for 2025
Carousel - Five Key FinTech Trends for 2025
Anadea
Account Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odooAccount Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odoo
AxisTechnolabs
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Philip Schwarz
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost OptimizationNext-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
asmith539880
LLM Security - Smart to protect, but too smart to be protected
LLM Security - Smart to protect, but too smart to be protectedLLM Security - Smart to protect, but too smart to be protected
LLM Security - Smart to protect, but too smart to be protected
Ivo Andreev
Tenorshare 4uKey Crack Fre e Download
Tenorshare  4uKey  Crack  Fre e DownloadTenorshare  4uKey  Crack  Fre e Download
Tenorshare 4uKey Crack Fre e Download
oyv9tzurtx
Metaverse Meetup: Explore Mulesoft MAC Project
Metaverse Meetup: Explore  Mulesoft MAC ProjectMetaverse Meetup: Explore  Mulesoft MAC Project
Metaverse Meetup: Explore Mulesoft MAC Project
GiulioPicchi
Code or No-Code Tests: Why Top Teams Choose Both
Code or No-Code Tests: Why Top Teams Choose BothCode or No-Code Tests: Why Top Teams Choose Both
Code or No-Code Tests: Why Top Teams Choose Both
Applitools
Advance Website Helpdesk Customer Support Ticket Management Odoo
Advance Website Helpdesk Customer Support Ticket Management OdooAdvance Website Helpdesk Customer Support Ticket Management Odoo
Advance Website Helpdesk Customer Support Ticket Management Odoo
Aagam infotech
SolidWorks 2025 Crack free Download updated
SolidWorks 2025 Crack  free Download updatedSolidWorks 2025 Crack  free Download updated
SolidWorks 2025 Crack free Download updated
sanasabaa73
salesforce development services - Alt digital
salesforce development services - Alt digitalsalesforce development services - Alt digital
salesforce development services - Alt digital
Alt Digital Technologies
Hire Odoo Developer OnestopDA Experts.
Hire Odoo Developer  OnestopDA Experts.Hire Odoo Developer  OnestopDA Experts.
Hire Odoo Developer OnestopDA Experts.
OnestopDA
AutoDesk Revit Crack | Revit Update 2025 free download
AutoDesk Revit Crack | Revit Update 2025 free downloadAutoDesk Revit Crack | Revit Update 2025 free download
AutoDesk Revit Crack | Revit Update 2025 free download
anamaslam971
SE- Lecture 5 for software development.ppt
SE- Lecture 5 for software development.pptSE- Lecture 5 for software development.ppt
SE- Lecture 5 for software development.ppt
theworldimagine985
EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]
bhagasufyan
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Yann-Ga谷l Gu辿h辿neuc
Elastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - VirtualElastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - Virtual
Gon巽alo Pereira
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP SolutionsWhy Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Absolute ERP
ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?
ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?
ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?
Ava Isley
Douwan Preactivated Plus Crack 2025-Latest
Douwan Preactivated Plus Crack 2025-LatestDouwan Preactivated Plus Crack 2025-Latest
Douwan Preactivated Plus Crack 2025-Latest
mubeen010khan
Carousel - Five Key FinTech Trends for 2025
Carousel - Five Key FinTech Trends for 2025Carousel - Five Key FinTech Trends for 2025
Carousel - Five Key FinTech Trends for 2025
Anadea
Account Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odooAccount Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odoo
AxisTechnolabs
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Philip Schwarz
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost OptimizationNext-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
asmith539880
LLM Security - Smart to protect, but too smart to be protected
LLM Security - Smart to protect, but too smart to be protectedLLM Security - Smart to protect, but too smart to be protected
LLM Security - Smart to protect, but too smart to be protected
Ivo Andreev
Tenorshare 4uKey Crack Fre e Download
Tenorshare  4uKey  Crack  Fre e DownloadTenorshare  4uKey  Crack  Fre e Download
Tenorshare 4uKey Crack Fre e Download
oyv9tzurtx
Metaverse Meetup: Explore Mulesoft MAC Project
Metaverse Meetup: Explore  Mulesoft MAC ProjectMetaverse Meetup: Explore  Mulesoft MAC Project
Metaverse Meetup: Explore Mulesoft MAC Project
GiulioPicchi
Code or No-Code Tests: Why Top Teams Choose Both
Code or No-Code Tests: Why Top Teams Choose BothCode or No-Code Tests: Why Top Teams Choose Both
Code or No-Code Tests: Why Top Teams Choose Both
Applitools
Advance Website Helpdesk Customer Support Ticket Management Odoo
Advance Website Helpdesk Customer Support Ticket Management OdooAdvance Website Helpdesk Customer Support Ticket Management Odoo
Advance Website Helpdesk Customer Support Ticket Management Odoo
Aagam infotech
SolidWorks 2025 Crack free Download updated
SolidWorks 2025 Crack  free Download updatedSolidWorks 2025 Crack  free Download updated
SolidWorks 2025 Crack free Download updated
sanasabaa73
salesforce development services - Alt digital
salesforce development services - Alt digitalsalesforce development services - Alt digital
salesforce development services - Alt digital
Alt Digital Technologies
Hire Odoo Developer OnestopDA Experts.
Hire Odoo Developer  OnestopDA Experts.Hire Odoo Developer  OnestopDA Experts.
Hire Odoo Developer OnestopDA Experts.
OnestopDA
AutoDesk Revit Crack | Revit Update 2025 free download
AutoDesk Revit Crack | Revit Update 2025 free downloadAutoDesk Revit Crack | Revit Update 2025 free download
AutoDesk Revit Crack | Revit Update 2025 free download
anamaslam971
SE- Lecture 5 for software development.ppt
SE- Lecture 5 for software development.pptSE- Lecture 5 for software development.ppt
SE- Lecture 5 for software development.ppt
theworldimagine985
EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]
bhagasufyan
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Yann-Ga谷l Gu辿h辿neuc
Elastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - VirtualElastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - Virtual
Gon巽alo Pereira
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP SolutionsWhy Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Absolute ERP
ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?
ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?
ChatGPT and DeepSeek: Which AI Tool Delivers Better User Experience?
Ava Isley
Douwan Preactivated Plus Crack 2025-Latest
Douwan Preactivated Plus Crack 2025-LatestDouwan Preactivated Plus Crack 2025-Latest
Douwan Preactivated Plus Crack 2025-Latest
mubeen010khan

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 computers 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.