SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot (20)

Functions in c++
Functions in c++Functions in c++
Functions in c++
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
C functions
C functionsC functions
C functions
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
File in c
File in cFile in c
File in c
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Virtual base class
Virtual base classVirtual base class
Virtual base class
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Call by value
Call by valueCall by value
Call by value
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)
 
Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Function overloading ppt
Function overloading pptFunction overloading ppt
Function overloading ppt
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Function in c
Function in cFunction in c
Function in c
 
functions of C++
functions of C++functions of C++
functions of C++
 
C++ Programming
C++ ProgrammingC++ Programming
C++ Programming
 
Memory allocation in c
Memory allocation in cMemory allocation in c
Memory allocation in c
 

Viewers also liked

Arrays Class presentation
Arrays Class presentationArrays Class presentation
Arrays Class presentationNeveen Reda
 
Array in c language
Array in c languageArray in c language
Array in c languagehome
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functionsHarsh Patel
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppteShikshak
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)EngineerBabu
 
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 computingeShikshak
 
structure and union
structure and unionstructure and union
structure and unionstudent
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functionsMarlom46
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : ArraysGagan Deep
 

Viewers also liked (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 in C
Structure in CStructure in C
Structure in C
 
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
 

Similar to Array within a class

Implementation of oop concept in c++
Implementation of oop concept in c++Implementation of oop concept in c++
Implementation of oop concept in c++Swarup Boro
 
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
 
Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)SURBHI SAROHA
 
Object oriented programming 2
Object oriented programming 2Object oriented programming 2
Object oriented programming 2Aadil Ansari
 
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 MelayiMuhammed Thanveer M
 
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptxINTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptx
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING.pptxDeepasCSE
 
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 LanguageJenish Bhavsar
 
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 variablesSaurav Kumar
 
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)Abu Saleh
 
3 functions and class
3   functions and class3   functions and class
3 functions and classtrixiacruz
 
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 210Mahmoud Samir Fayed
 
Introduction to object oriented programming concepts
Introduction to object oriented programming conceptsIntroduction to object oriented programming concepts
Introduction to object oriented programming conceptsGanesh Karthik
 
Functions and Modules.pptx
Functions and Modules.pptxFunctions and Modules.pptx
Functions and Modules.pptxAshwini Raut
 
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 .pdfRahul04August
 
CLASSES, STRUCTURE,UNION in C++
CLASSES, STRUCTURE,UNION in C++CLASSES, STRUCTURE,UNION in C++
CLASSES, STRUCTURE,UNION in C++Prof Ansari
 

Similar to 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++
 

More from AAKASH KUMAR

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|...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 CSAAKASH KUMAR
 
Inheritance question
Inheritance questionInheritance question
Inheritance questionAAKASH KUMAR
 
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 12THAAKASH KUMAR
 
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 12thAAKASH KUMAR
 
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 EXAMAAKASH KUMAR
 
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 12thAAKASH 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 CSAAKASH KUMAR
 
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 || ...AAKASH KUMAR
 
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 || ...AAKASH KUMAR
 
Inheritance question class 12th
Inheritance question class 12thInheritance question class 12th
Inheritance question class 12thAAKASH KUMAR
 
Power point2007instruction
Power point2007instructionPower point2007instruction
Power point2007instructionAAKASH KUMAR
 
Html introduction Part-2
Html introduction Part-2Html introduction Part-2
Html introduction Part-2AAKASH KUMAR
 
Evolution / history of Computer
Evolution / history of ComputerEvolution / history of Computer
Evolution / history of ComputerAAKASH KUMAR
 
Input Output Devices and Memory Unit
Input Output Devices and Memory UnitInput Output Devices and Memory Unit
Input Output Devices and Memory UnitAAKASH KUMAR
 
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 controlAAKASH KUMAR
 
c++ programming Unit 4 operators
c++ programming Unit 4 operatorsc++ programming Unit 4 operators
c++ programming Unit 4 operatorsAAKASH KUMAR
 

More from 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
 

Recently uploaded

Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 

Recently uploaded (20)

Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 

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.