SlideShare a Scribd company logo
FUNCTIONS
• Function is the building block of C++.
• Used to reduce the size of the program by
calling and using them in different places in
the program.
• main()Function returns an integer value.
int main();
int main(int arg);
 Function return a value using return statement.
FUNCTION PROTOTYPE
• The function interface to the compiler by
giving the details like number, data type,
arguments – function prototype.
• It is a declaration statement in calling program
type function name (argument list);
Eg:
float volume (int x, float y, z);
float volume (int, float, float);
CALL BY REFERENCE
• C++ permits to pass the parameters to the
functions by reference variable.
• When it is passed the formal argument act as
the actual argument in the calling function
void swap(int a, int b)
{
int t = a;
a = b;
b = t;
}
INLINE & RECURSION FUNCTION
• An inline function is a function that is expanded in
line when it is invoked.
• The compiler replaces the function call with the
corresponding function code.
inline function header
{
function body
}
• It send a request not a command
• Recursion means function call by itself ie one of the
statement in the function definition makes a call to
the same in which it is present.
CLASS
• Collection of objects – CLASS
• The entire set of data and code of an object can
be made a user defined data type by using
class.
• 2 Parts:
– Class Declaration – describe the type & scope of
its members
– Class function definitions – how the class
function are implemented.
• General format:
class class-name
{
private:
variable declaration;
function declaration;
public:
variable declaration;
function declaration;
};
Class item
{
int number;
float cost;
public:
void getdata(int a, float b);
void putdata(void);
};
• Class member – the class body contains the
declaration of variables and functions.
• Data member – variables declared inside the
class.
• Member function – the function declared
inside the class.
DEFINING MEMBER FUNCTIONS
• Done by 2 ways
1. Outside the class definition
2. Inside the class definition
Outside the class definition
• Member function declared inside the class has to be
defined separately outside the class.
return-type class-name :: function-name
(argument declaration)
{
function body;
}
void item :: getdata (int a , float b)
{
number = a;
cost = b;
}
void item :: putdata (void)
{
cout<< “Number : “ << number;
cout << “Cost : “ << cost;
}
Inside the class definition
• It is to replace the function declaration by the actual
function definition inside the class.
class item
{
int number;
float cost;
public:
void getdata(int a, float b);
void putdata(void)
{
cout << number;
cout << cost;
}
};
Functions, classes & objects in c++

More Related Content

What's hot

4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
Praveen M Jigajinni
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
Mayank Jain
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
rprajat007
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
Class or Object
Class or ObjectClass or Object
Class or Object
Rahul Bathri
 
Object and class
Object and classObject and class
Object and class
mohit tripathi
 
C++ classes
C++ classesC++ classes
C++ classes
imhammadali
 
Class and object in c++
Class and object in c++Class and object in c++
Class and object in c++
NainaKhan28
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
Nilesh Dalvi
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
Marlom46
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
kailash454
 
OOP C++
OOP C++OOP C++
OOP C++
Ahmed Farag
 
class and objects
class and objectsclass and objects
class and objectsPayel Guria
 
Class object method constructors in java
Class object method constructors in javaClass object method constructors in java
Class object method constructors in java
Raja Sekhar
 
Learn Concept of Class and Object in C# Part 3
Learn Concept of Class and Object in C#  Part 3Learn Concept of Class and Object in C#  Part 3
Learn Concept of Class and Object in C# Part 3
C# Learning Classes
 
Lect 1-class and object
Lect 1-class and objectLect 1-class and object
Lect 1-class and object
Fajar Baskoro
 
Classes and objects till 16 aug
Classes and objects till 16 augClasses and objects till 16 aug
Classes and objects till 16 augshashank12march
 

What's hot (20)

4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Class or Object
Class or ObjectClass or Object
Class or Object
 
Object and class
Object and classObject and class
Object and class
 
C++ classes
C++ classesC++ classes
C++ classes
 
Class and object in c++
Class and object in c++Class and object in c++
Class and object in c++
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
Introduction to c ++ part -2
Introduction to c ++   part -2Introduction to c ++   part -2
Introduction to c ++ part -2
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
OOP C++
OOP C++OOP C++
OOP C++
 
class and objects
class and objectsclass and objects
class and objects
 
Class object method constructors in java
Class object method constructors in javaClass object method constructors in java
Class object method constructors in java
 
Learn Concept of Class and Object in C# Part 3
Learn Concept of Class and Object in C#  Part 3Learn Concept of Class and Object in C#  Part 3
Learn Concept of Class and Object in C# Part 3
 
Lect 1-class and object
Lect 1-class and objectLect 1-class and object
Lect 1-class and object
 
Classes and objects till 16 aug
Classes and objects till 16 augClasses and objects till 16 aug
Classes and objects till 16 aug
 
ccc
cccccc
ccc
 

Similar to Functions, classes & objects in c++

Function class in c++
Function class in c++Function class in c++
Function class in c++Kumar
 
Function different types of funtion
Function different types of funtionFunction different types of funtion
Function different types of funtion
svishalsingh01
 
CH.4FUNCTIONS IN C (1).pptx
CH.4FUNCTIONS IN C (1).pptxCH.4FUNCTIONS IN C (1).pptx
CH.4FUNCTIONS IN C (1).pptx
sangeeta borde
 
Functions
FunctionsFunctions
Functions in c
Functions in cFunctions in c
Functions in c
sunila tharagaturi
 
UNIT3 on object oriented programming.pptx
UNIT3 on object oriented programming.pptxUNIT3 on object oriented programming.pptx
UNIT3 on object oriented programming.pptx
urvashipundir04
 
arrays.ppt
arrays.pptarrays.ppt
arrays.ppt
Bharath904863
 
c++ Unit I.pptx
c++ Unit I.pptxc++ Unit I.pptx
Functions
FunctionsFunctions
1.6 Function.pdf
1.6 Function.pdf1.6 Function.pdf
1.6 Function.pdf
NirmalaShinde3
 
Function (rule in programming)
Function (rule in programming)Function (rule in programming)
Function (rule in programming)
Unviersity of balochistan quetta
 
unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
Venkatesh Goud
 
PSPC-UNIT-4.pdf
PSPC-UNIT-4.pdfPSPC-UNIT-4.pdf
PSPC-UNIT-4.pdf
ArshiniGubbala3
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
Anil Pokhrel
 
FUNCTIONS IN C.pptx
FUNCTIONS IN C.pptxFUNCTIONS IN C.pptx
FUNCTIONS IN C.pptx
SKUP1
 
FUNCTIONS IN C.pptx
FUNCTIONS IN C.pptxFUNCTIONS IN C.pptx
FUNCTIONS IN C.pptx
LECO9
 
Funtions of c programming. the functions of c helps to clarify all the tops
Funtions of c programming. the functions of c helps to clarify all the topsFuntions of c programming. the functions of c helps to clarify all the tops
Funtions of c programming. the functions of c helps to clarify all the tops
sameermhr345
 
C++.pptx
C++.pptxC++.pptx
object oriented programming language.pptx
object oriented programming language.pptxobject oriented programming language.pptx
object oriented programming language.pptx
syedabbas594247
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
JVenkateshGoud
 

Similar to Functions, classes & objects in c++ (20)

Function class in c++
Function class in c++Function class in c++
Function class in c++
 
Function different types of funtion
Function different types of funtionFunction different types of funtion
Function different types of funtion
 
CH.4FUNCTIONS IN C (1).pptx
CH.4FUNCTIONS IN C (1).pptxCH.4FUNCTIONS IN C (1).pptx
CH.4FUNCTIONS IN C (1).pptx
 
Functions
FunctionsFunctions
Functions
 
Functions in c
Functions in cFunctions in c
Functions in c
 
UNIT3 on object oriented programming.pptx
UNIT3 on object oriented programming.pptxUNIT3 on object oriented programming.pptx
UNIT3 on object oriented programming.pptx
 
arrays.ppt
arrays.pptarrays.ppt
arrays.ppt
 
c++ Unit I.pptx
c++ Unit I.pptxc++ Unit I.pptx
c++ Unit I.pptx
 
Functions
FunctionsFunctions
Functions
 
1.6 Function.pdf
1.6 Function.pdf1.6 Function.pdf
1.6 Function.pdf
 
Function (rule in programming)
Function (rule in programming)Function (rule in programming)
Function (rule in programming)
 
unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
 
PSPC-UNIT-4.pdf
PSPC-UNIT-4.pdfPSPC-UNIT-4.pdf
PSPC-UNIT-4.pdf
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
FUNCTIONS IN C.pptx
FUNCTIONS IN C.pptxFUNCTIONS IN C.pptx
FUNCTIONS IN C.pptx
 
FUNCTIONS IN C.pptx
FUNCTIONS IN C.pptxFUNCTIONS IN C.pptx
FUNCTIONS IN C.pptx
 
Funtions of c programming. the functions of c helps to clarify all the tops
Funtions of c programming. the functions of c helps to clarify all the topsFuntions of c programming. the functions of c helps to clarify all the tops
Funtions of c programming. the functions of c helps to clarify all the tops
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
 
object oriented programming language.pptx
object oriented programming language.pptxobject oriented programming language.pptx
object oriented programming language.pptx
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
 

More from ThamizhselviKrishnam

Standard template library
Standard template libraryStandard template library
Standard template library
ThamizhselviKrishnam
 
Templates in c++
Templates in c++Templates in c++
Templates in c++
ThamizhselviKrishnam
 
Operators and expression in c++
Operators and  expression in c++Operators and  expression in c++
Operators and expression in c++
ThamizhselviKrishnam
 
Page maker - working with text
Page maker - working with textPage maker - working with text
Page maker - working with text
ThamizhselviKrishnam
 
Microprocessor & architecture
Microprocessor & architectureMicroprocessor & architecture
Microprocessor & architecture
ThamizhselviKrishnam
 
Instruction set of 8085
Instruction set of 8085Instruction set of 8085
Instruction set of 8085
ThamizhselviKrishnam
 
Memory and storage devices
Memory and storage devicesMemory and storage devices
Memory and storage devices
ThamizhselviKrishnam
 
Generations of computer
Generations of computerGenerations of computer
Generations of computer
ThamizhselviKrishnam
 
Adobe Pagemaker 7.0
Adobe Pagemaker 7.0Adobe Pagemaker 7.0
Adobe Pagemaker 7.0
ThamizhselviKrishnam
 
classification of digital computer
classification of digital computerclassification of digital computer
classification of digital computer
ThamizhselviKrishnam
 
Pagemaker
PagemakerPagemaker

More from ThamizhselviKrishnam (11)

Standard template library
Standard template libraryStandard template library
Standard template library
 
Templates in c++
Templates in c++Templates in c++
Templates in c++
 
Operators and expression in c++
Operators and  expression in c++Operators and  expression in c++
Operators and expression in c++
 
Page maker - working with text
Page maker - working with textPage maker - working with text
Page maker - working with text
 
Microprocessor & architecture
Microprocessor & architectureMicroprocessor & architecture
Microprocessor & architecture
 
Instruction set of 8085
Instruction set of 8085Instruction set of 8085
Instruction set of 8085
 
Memory and storage devices
Memory and storage devicesMemory and storage devices
Memory and storage devices
 
Generations of computer
Generations of computerGenerations of computer
Generations of computer
 
Adobe Pagemaker 7.0
Adobe Pagemaker 7.0Adobe Pagemaker 7.0
Adobe Pagemaker 7.0
 
classification of digital computer
classification of digital computerclassification of digital computer
classification of digital computer
 
Pagemaker
PagemakerPagemaker
Pagemaker
 

Recently uploaded

To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 

Recently uploaded (20)

To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 

Functions, classes & objects in c++

  • 1.
  • 2. FUNCTIONS • Function is the building block of C++. • Used to reduce the size of the program by calling and using them in different places in the program. • main()Function returns an integer value. int main(); int main(int arg);  Function return a value using return statement.
  • 3. FUNCTION PROTOTYPE • The function interface to the compiler by giving the details like number, data type, arguments – function prototype. • It is a declaration statement in calling program type function name (argument list); Eg: float volume (int x, float y, z); float volume (int, float, float);
  • 4. CALL BY REFERENCE • C++ permits to pass the parameters to the functions by reference variable. • When it is passed the formal argument act as the actual argument in the calling function void swap(int a, int b) { int t = a; a = b; b = t; }
  • 5. INLINE & RECURSION FUNCTION • An inline function is a function that is expanded in line when it is invoked. • The compiler replaces the function call with the corresponding function code. inline function header { function body } • It send a request not a command • Recursion means function call by itself ie one of the statement in the function definition makes a call to the same in which it is present.
  • 6. CLASS • Collection of objects – CLASS • The entire set of data and code of an object can be made a user defined data type by using class. • 2 Parts: – Class Declaration – describe the type & scope of its members – Class function definitions – how the class function are implemented.
  • 7. • General format: class class-name { private: variable declaration; function declaration; public: variable declaration; function declaration; }; Class item { int number; float cost; public: void getdata(int a, float b); void putdata(void); };
  • 8. • Class member – the class body contains the declaration of variables and functions. • Data member – variables declared inside the class. • Member function – the function declared inside the class.
  • 9. DEFINING MEMBER FUNCTIONS • Done by 2 ways 1. Outside the class definition 2. Inside the class definition
  • 10. Outside the class definition • Member function declared inside the class has to be defined separately outside the class. return-type class-name :: function-name (argument declaration) { function body; }
  • 11. void item :: getdata (int a , float b) { number = a; cost = b; } void item :: putdata (void) { cout<< “Number : “ << number; cout << “Cost : “ << cost; }
  • 12. Inside the class definition • It is to replace the function declaration by the actual function definition inside the class. class item { int number; float cost; public: void getdata(int a, float b); void putdata(void) { cout << number; cout << cost; } };