SlideShare una empresa de Scribd logo
1 de 14
Array within a Class
AS WE HAVE ARRAYS WITHIN A STRUCTURE. IN THE SAME WE CAN HAVE
ARRAYS AS A DATA MEMBER WITHIN A CLASS ALSO. THEY CAN BE
DECLARED EITHER IN PRIVATE OR PROTECTED OR PUBLIC SECTION.
Example:- Array as data member of Class
 Class student
 {
 Int rollno;
 Char name[50];
 Int marks[5]; // arrary of 5 intgers variables to store marks in
5 subjects.
 Int total;
 Float average;
 Public:
 Void getstuddetails();
 Void printstuddetails();
};
Void student:: getstuddetails()
{
cout<<“Enter rollno”;
cin>>rollno;
cout<<“Enter Name”;
gets(name);
total=0;
cout<<“Enter marks in 5 sujects”;
for(int i=0;i<5;i++)
{
cout<<“Subjet “<< i+1<<“t”;
cin>>marks[i];
total=total+marks[i];
}
}
 Void student :: printstuddetails()
 {
 Cout<<“Rollno t:t”<<rollno;
 Cout<<“Name t:t”<<namel
 Cout<<“Marks Details”;
 For(int i=0;i<5;i++)
 {
 Cout<<“Subject “<<i+1<<“t:t”<<marks[i];
 }
 Cout<<“total t:t “<<total;
 Cout<<“Average t :t “<<average;
 }
Array of Objects
 As we can declare array of integer, float, characters and array of
structure variables in the same way C++ also supports Array of objects
also.
 An array of objects is declared in the same way as we had declared
array of structure variables.
Example:- In continuation with the previous
example of array within a class
 Void main()
 {
 Student xa[10];
 Cout<<“Enter detail of 10 students of x a class”;
 for(int i=;i<10;i++)
 {
 Xa[i].getstuddetails();
 }
 Cout<<“Details entered by you are shown below”;
 For(i=0;i<10;i++)
 {
 Xa[i].printstuddetails();
 }
 }
Nested Class
As of nested condition (conditions within conditions) and nested loops (loops
within loop). We can also declare Nested class.
 A class declared within another class is called a nested class.
 The outer class is known as enclosing class.
 The inner class is known as nested class.
 We can declare the inner class (nested class) in any section of the outer
class (enclosing class) i.e. private , public or protected.
 If we declare inner class in private section then we will be able to declare
the objects of inner class within outer class only or you can’t declare object
of inner class (declared in private section) Outside the outer class(its
enclosing class).
 If the nested class definition in under public section the object of
inner class can be declared outside the outer class but by specifying
full qualified names. Only.
Example:
Outerclassname :: innerclassname objname;
Example 1:- Nested class declared in private
section
Functions in a Class
Different type of functions can be declared within a Class.
 Inline function
 Constant functions
 Nested functions
Inline functions
 It is an enhancement of C++ to speed up the execution of a program.
 Coding of inline function is same as normal function but the definition
of inline function starts / precedes with the keyword inline.
 Difference between normal and inline function is the different
compilation process of them.
Execution process of a normal function
 1001 int a=4, b=7; Memory loaded code scenario
 1002 int c= a+b, d; with memory addresses of
 1003 d=square ( c); instruction to be executed.
 1004 cout<<d;
 2011int square(int i)
 {
 Return i*I;
 }
Whenever in the execution of a program a function call takes place a
lot of function calling overheads involved.
 The address of the next instruction ( nest to the function calling
instruction) is saved in the memory.
i.e. 1004 address will be saved in the memory
 The argument passed to function will be copied into system stack
(local variable storage area) i.e. value of c (11) will be loaded into
stack.
 Jump to the memory address of called function i.e. jump to 2011
address
 Execute the function i.e. calculate 11 X 11 and return the result
 Store the return value into d.
 Fetch the address saved in step 1 and jump to that address (1004)
start further execution.
Array within a class

Más contenido relacionado

La actualidad más candente

Inline function
Inline functionInline function
Inline function
Tech_MX
 

La actualidad más candente (20)

INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
 
File operations in c
File operations in cFile operations in c
File operations in c
 
Strings and pointers
Strings and pointersStrings and pointers
Strings and pointers
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Friend function in c++
Friend function in c++ Friend function in c++
Friend function in c++
 
User defined functions in C programmig
User defined functions in C programmigUser defined functions in C programmig
User defined functions in C programmig
 
Static variables
Static variablesStatic variables
Static variables
 
Inline function
Inline functionInline function
Inline function
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
 
Structure in C
Structure in CStructure in C
Structure in C
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Pointers - DataStructures
Pointers - DataStructuresPointers - DataStructures
Pointers - DataStructures
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
 
Function in C
Function in CFunction in C
Function in C
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
friend function(c++)
friend function(c++)friend function(c++)
friend function(c++)
 

Destacado

Arrays Class presentation
Arrays Class presentationArrays Class presentation
Arrays Class presentation
Neveen Reda
 
Array in c language
Array in c languageArray in c language
Array in c language
home
 
structure and union
structure and unionstructure and union
structure and union
student
 

Destacado (20)

Arrays Class presentation
Arrays Class presentationArrays Class presentation
Arrays Class presentation
 
Array in C
Array in CArray in C
Array in C
 
Array in c language
Array in c languageArray in c language
Array in c language
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppt
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)
 
Arrays
ArraysArrays
Arrays
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
Type Casting in C++
Type Casting in C++Type Casting in C++
Type Casting in C++
 
Ms word Part 2
Ms  word Part 2Ms  word Part 2
Ms word Part 2
 
Lecture 01 2017
Lecture 01 2017Lecture 01 2017
Lecture 01 2017
 
Unit 1.2 move to cloud computing
Unit 1.2   move to cloud computingUnit 1.2   move to cloud computing
Unit 1.2 move to cloud computing
 
Structure in c
Structure in cStructure in c
Structure in c
 
Structure in c
Structure in cStructure in c
Structure in c
 
C Structures & Unions
C Structures & UnionsC Structures & Unions
C Structures & Unions
 
structure and union
structure and unionstructure and union
structure and union
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 
C++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLESC++ ARRAY WITH EXAMPLES
C++ ARRAY WITH EXAMPLES
 
0. Course Introduction
0. Course Introduction0. Course Introduction
0. Course Introduction
 

Similar a Array within a class

Object Oriented Programming using C++(UNIT 1)
Object Oriented Programming using C++(UNIT 1)Object Oriented Programming using C++(UNIT 1)
Object Oriented Programming using C++(UNIT 1)
SURBHI SAROHA
 
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptxINTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
DeepasCSE
 
Function class in c++
Function class in c++Function class in c++
Function class in c++
Kumar
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
Saurav Kumar
 
3 functions and class
3   functions and class3   functions and class
3 functions and class
trixiacruz
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdf
Rahul04August
 

Similar a Array within a class (20)

Bc0037
Bc0037Bc0037
Bc0037
 
Implementation of oop concept in c++
Implementation of oop concept in c++Implementation of oop concept in c++
Implementation of oop concept in c++
 
Object Oriented Programming using C++(UNIT 1)
Object Oriented Programming using C++(UNIT 1)Object Oriented Programming using C++(UNIT 1)
Object Oriented Programming using C++(UNIT 1)
 
Core java oop
Core java oopCore java oop
Core java oop
 
Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)
 
OOC MODULE1.pptx
OOC MODULE1.pptxOOC MODULE1.pptx
OOC MODULE1.pptx
 
Object oriented programming 2
Object oriented programming 2Object oriented programming 2
Object oriented programming 2
 
Oop concept in c++ by MUhammed Thanveer Melayi
Oop concept in c++ by MUhammed Thanveer MelayiOop concept in c++ by MUhammed Thanveer Melayi
Oop concept in c++ by MUhammed Thanveer Melayi
 
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptxINTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
 
Storage classes arrays & functions in C Language
Storage classes arrays & functions in C LanguageStorage classes arrays & functions in C Language
Storage classes arrays & functions in C Language
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
 
Function class in c++
Function class in c++Function class in c++
Function class in c++
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)
 
3 functions and class
3   functions and class3   functions and class
3 functions and class
 
The Ring programming language version 1.9 book - Part 39 of 210
The Ring programming language version 1.9 book - Part 39 of 210The Ring programming language version 1.9 book - Part 39 of 210
The Ring programming language version 1.9 book - Part 39 of 210
 
Introduction to object oriented programming concepts
Introduction to object oriented programming conceptsIntroduction to object oriented programming concepts
Introduction to object oriented programming concepts
 
Functions and Modules.pptx
Functions and Modules.pptxFunctions and Modules.pptx
Functions and Modules.pptx
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdf
 
CLASSES, STRUCTURE,UNION in C++
CLASSES, STRUCTURE,UNION in C++CLASSES, STRUCTURE,UNION in C++
CLASSES, STRUCTURE,UNION in C++
 

Más de AAKASH KUMAR

2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
AAKASH KUMAR
 
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
AAKASH KUMAR
 

Más de AAKASH KUMAR (20)

NETWORKING AND COMMUNICATION || SLIDE 1 || TOPOLOGY AND PLACEMENT OF DEVICES|...
NETWORKING AND COMMUNICATION || SLIDE 1 || TOPOLOGY AND PLACEMENT OF DEVICES|...NETWORKING AND COMMUNICATION || SLIDE 1 || TOPOLOGY AND PLACEMENT OF DEVICES|...
NETWORKING AND COMMUNICATION || SLIDE 1 || TOPOLOGY AND PLACEMENT OF DEVICES|...
 
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 2) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
 
Inheritance question
Inheritance questionInheritance question
Inheritance question
 
Header file BASED QUESTION- CBSE CS CLASS 12TH
Header file BASED QUESTION- CBSE CS CLASS 12THHeader file BASED QUESTION- CBSE CS CLASS 12TH
Header file BASED QUESTION- CBSE CS CLASS 12TH
 
Constructor & destructor based question- cbse cs class 12th
Constructor & destructor based question-  cbse cs class 12thConstructor & destructor based question-  cbse cs class 12th
Constructor & destructor based question- cbse cs class 12th
 
CHOOSE THE CORRECT IDENTIFIER - Q.1 CBSE CS EXAM
CHOOSE THE CORRECT IDENTIFIER - Q.1 CBSE CS EXAMCHOOSE THE CORRECT IDENTIFIER - Q.1 CBSE CS EXAM
CHOOSE THE CORRECT IDENTIFIER - Q.1 CBSE CS EXAM
 
Practical exam special- CBSE CS CLASS 12th
Practical exam special- CBSE CS CLASS 12thPractical exam special- CBSE CS CLASS 12th
Practical exam special- CBSE CS CLASS 12th
 
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
 
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
STACK || FUNCTION WRITING BASED ON STACK || DATA STRUCTURE || LINKED LIST || ...
 
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
 
Inheritance question class 12th
Inheritance question class 12thInheritance question class 12th
Inheritance question class 12th
 
Ms word Part 1
Ms  word Part 1Ms  word Part 1
Ms word Part 1
 
Power point2007instruction
Power point2007instructionPower point2007instruction
Power point2007instruction
 
Html introduction Part-2
Html introduction Part-2Html introduction Part-2
Html introduction Part-2
 
Html Slide Part-1
Html Slide Part-1Html Slide Part-1
Html Slide Part-1
 
Evolution / history of Computer
Evolution / history of ComputerEvolution / history of Computer
Evolution / history of Computer
 
computer system
computer system computer system
computer system
 
Input Output Devices and Memory Unit
Input Output Devices and Memory UnitInput Output Devices and Memory Unit
Input Output Devices and Memory Unit
 
C++ programming Unit 5 flow of control
C++ programming Unit 5 flow of controlC++ programming Unit 5 flow of control
C++ programming Unit 5 flow of control
 
c++ programming Unit 4 operators
c++ programming Unit 4 operatorsc++ programming Unit 4 operators
c++ programming Unit 4 operators
 

Último

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Último (20)

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 

Array within a class

  • 1. Array within a Class AS WE HAVE ARRAYS WITHIN A STRUCTURE. IN THE SAME WE CAN HAVE ARRAYS AS A DATA MEMBER WITHIN A CLASS ALSO. THEY CAN BE DECLARED EITHER IN PRIVATE OR PROTECTED OR PUBLIC SECTION.
  • 2. Example:- Array as data member of Class  Class student  {  Int rollno;  Char name[50];  Int marks[5]; // arrary of 5 intgers variables to store marks in 5 subjects.  Int total;  Float average;  Public:  Void getstuddetails();  Void printstuddetails(); }; Void student:: getstuddetails() { cout<<“Enter rollno”; cin>>rollno; cout<<“Enter Name”; gets(name); total=0; cout<<“Enter marks in 5 sujects”; for(int i=0;i<5;i++) { cout<<“Subjet “<< i+1<<“t”; cin>>marks[i]; total=total+marks[i]; } }
  • 3.  Void student :: printstuddetails()  {  Cout<<“Rollno t:t”<<rollno;  Cout<<“Name t:t”<<namel  Cout<<“Marks Details”;  For(int i=0;i<5;i++)  {  Cout<<“Subject “<<i+1<<“t:t”<<marks[i];  }  Cout<<“total t:t “<<total;  Cout<<“Average t :t “<<average;  }
  • 4. Array of Objects  As we can declare array of integer, float, characters and array of structure variables in the same way C++ also supports Array of objects also.  An array of objects is declared in the same way as we had declared array of structure variables.
  • 5. Example:- In continuation with the previous example of array within a class  Void main()  {  Student xa[10];  Cout<<“Enter detail of 10 students of x a class”;  for(int i=;i<10;i++)  {  Xa[i].getstuddetails();  }  Cout<<“Details entered by you are shown below”;  For(i=0;i<10;i++)  {  Xa[i].printstuddetails();  }  }
  • 6. Nested Class As of nested condition (conditions within conditions) and nested loops (loops within loop). We can also declare Nested class.  A class declared within another class is called a nested class.  The outer class is known as enclosing class.  The inner class is known as nested class.  We can declare the inner class (nested class) in any section of the outer class (enclosing class) i.e. private , public or protected.  If we declare inner class in private section then we will be able to declare the objects of inner class within outer class only or you can’t declare object of inner class (declared in private section) Outside the outer class(its enclosing class).
  • 7.  If the nested class definition in under public section the object of inner class can be declared outside the outer class but by specifying full qualified names. Only. Example: Outerclassname :: innerclassname objname;
  • 8. Example 1:- Nested class declared in private section
  • 9. Functions in a Class Different type of functions can be declared within a Class.  Inline function  Constant functions  Nested functions
  • 10. Inline functions  It is an enhancement of C++ to speed up the execution of a program.  Coding of inline function is same as normal function but the definition of inline function starts / precedes with the keyword inline.  Difference between normal and inline function is the different compilation process of them.
  • 11. Execution process of a normal function  1001 int a=4, b=7; Memory loaded code scenario  1002 int c= a+b, d; with memory addresses of  1003 d=square ( c); instruction to be executed.  1004 cout<<d;  2011int square(int i)  {  Return i*I;  }
  • 12. Whenever in the execution of a program a function call takes place a lot of function calling overheads involved.  The address of the next instruction ( nest to the function calling instruction) is saved in the memory. i.e. 1004 address will be saved in the memory  The argument passed to function will be copied into system stack (local variable storage area) i.e. value of c (11) will be loaded into stack.  Jump to the memory address of called function i.e. jump to 2011 address
  • 13.  Execute the function i.e. calculate 11 X 11 and return the result  Store the return value into d.  Fetch the address saved in step 1 and jump to that address (1004) start further execution.