SlideShare a Scribd company logo
1 of 24
OBJECT IN OOP
Objects
 An object is an instance of a class.
 An object is a class variable.
 Is can be uniquely identified by its name.
 Every object have a state which is represented by the
values of its attributes. These state are changed by
function which applied on the object.
State identity and behavior of
objects
 Every object have identity , behavior and state.
 The identity of object is defined by its name, every
object is unique and can be differentiated from other
objects.
 The behavior of an object is represented by the
functions which are defined in the object’s class. These
function show the set of action for every objects.
 The state of objects are referred by the data stored
within the object at any time moment.
Creating an object of a Class
 Declaring a variable of a class type creates an object. You
can have many variables of the same type (class).
 Also known as Instantiation
 Once an object of a certain class is instantiated, a new
memory location is created for it to store its data members
and code
 You can instantiate many objects from a class type.
 Ex) Circle c; Circle *c;
Class item
{
……….
,,,,,,,,,,,,,
}x,y,z;
We have to declared objects close to the place where they are needed
because it makes easier to identify the objects.
Object types
 There are four types of objects
1. External (global )objects
1. This object have the existence throughout the lifetime of the program and
having file –scope.
2. Automatic(local)objects
1. Persistent and visible only throughout the local scope in which they are
created.
3. Static objects
1. Persistent throughout a program but only visible within their local scope.
4. Dynamic objects
1. Lifetime may be controlled within a particular scope.
Memory Allocation of Object
class student
{
int rollno;
char name[20];
int marks;
};
student s;
rollno – 2 bytes
name- 20 bytes
marks- 2 bytes
24 bytes s
Array of objects
 The array of class type variable is known as array of
object.
 We can declare array of object as following way:-
Class _name object [length];
Employee manager[3];
1. We can use this array when calling a member function
2. Manager[i].put data();
3. The array of object is stored in memory as a multi-
dimensional array.
Object as function arguments
 This can be done in two ways:-
 A copy of entire object is passed to the function.
 ( pass by value)
 Only the address of the object is transferred to the
function. (pass by reference)
( pass by value)
 A copy of the object is passed to the function, any
changes made to the object inside the function do not
affect the object used to call function.
 When an address of object is passed, the called
function works directly on the actual object used in
the call. Means that any change made in side the
function will reflect in the actual object.
(pass by reference)
Passing Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
void sum (Complex A, Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
void Complex : : sum ( complex A, complex B)
{
real = A.real + B.real;
imag= A.imag + B.imag;
}
void main( )
{
Complex X,Y,Z;
X.getdata( );
Y.getdata( );
Z.sum(X,Y);
Z.putdata( );
}
Passing Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
void sum (Complex A, Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
void Complex : : sum ( Complex A, Complex B)
{
real = A.real + B.real;
imag= A.imag + B.imag;
}
void main( )
{
Complex X,Y,Z;
X.getdata( );
Y.getdata( );
Z.sum(X,Y);
Z.putdata( );
}
X Y Z
Passing Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
void sum (Complex A, Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
void Complex : : sum ( Complex A, Complex B)
{
real = A.real + B.real;
imag= A.imag + B.imag;
}
void main( )
{
Complex X,Y,Z;
X.getdata( );
Y.getdata( );
Z.sum(X,Y);
Z.putdata( );
}
5
6
7
8
X Y Z
Passing Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
void sum (Complex A, Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
void Complex : : sum ( Complex A, Complex B)
{
real = A.real + B.real;
imag= A.imag + B.imag;
}
void main( )
{
Complex X,Y,Z;
X.getdata( );
Y.getdata( );
Z.sum(X,Y);
Z.putdata( );
}
5
6
7
8
X Y Z
5
6
7
8
A B
Passing Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
void sum(Complex A, Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
void Complex : : sum ( Complex A, Complex B)
{
real = A.real + B.real;
imag= A.imag + B.imag;
}
void main( )
{
Complex X,Y,Z;
X.getdata( );
Y.getdata( );
Z.sum(X,Y);
Z.putdata( );
}
5
6
7
8
12
14
X Y Z
5
6
7
8
A B
+
+
=
=
Passing Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
void sum (Complex A, Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
void complex : : sum ( Complex A, Complex B)
{
real = A.real + B.real;
imag= A.imag + B.imag;
}
void main( )
{
Complex X,Y,Z;
X.getdata( );
Y.getdata( );
Z.sum(X,Y);
Z.putdata( );
}
12 + 14 i
5
6
7
8
12
14
X Y Z
5
6
7
8
A B
+
+
=
=
Returning Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
Complex sum (Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
Complex Complex : : sum (Complex B)
{
Complex temp;
temp.real=real + B.real;
temp.imag= imag + B.imag;
return temp;
}
void main ( )
{
Complex X, Y, Z;
X.Getdata( );
Y. getdata( );
Z= X.sum (Y);
Z.putdata( );
}
Returning Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
Complex sum (Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
Complex Complex : : sum (Complex B)
{
Complex temp;
temp.real=real + B.real;
temp.imag= imag + B.imag;
return temp;
}
void main ( )
{
Complex X, Y, Z;
X.Getdata( );
Y. getdata( );
Z= X.sum (Y);
Z.putdata( );
}
X Y Z
Returning Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
Complex sum (Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
Complex Complex : : sum (Complex B)
{
Complex temp;
temp.real=real + B.real;
temp.imag= imag + B.imag;
return temp;
}
void main ( )
{
Complex X, Y, Z;
X.Getdata( );
Y. getdata( );
Z= X.sum (Y);
Z.putdata( );
}
5
6
7
8
X Y Z
Returning Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
Complex sum (Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
Complex Complex : : sum (Complex B)
{
Complex temp;
temp.real=real + B.real;
temp.imag= imag + B.imag;
return temp;
}
void main ( )
{
Complex X, Y, Z;
X.Getdata( );
Y. getdata( );
Z= X.sum (Y);
Z.putdata( );
}
5
6
7
8
X Y Z
7
8
B
Returning Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
Complex sum (Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
Complex Complex : : sum (Complex B)
{
Complex temp;
temp.real=real + B.real;
temp.imag= imag + B.imag;
return temp;
}
void main ( )
{
Complex X, Y, Z;
X.Getdata( );
Y. getdata( );
Z= X.sum (Y);
Z.putdata( );
}
5
6
7
8
X Y Z
7
8
B
Returning Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
Complex sum (Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
Complex Complex : : sum (Complex B)
{
Complex temp;
temp.real=real + B.real;
temp.imag= imag + B.imag;
return temp;
}
void main ( )
{
Complex X, Y, Z;
X.Getdata( );
Y. getdata( );
Z= X.sum (Y);
Z.putdata( );
}
5
6
7
8
X Y Z
7
8
B
12
14
temp
Returning Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
Complex sum (Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
Complex Complex : : sum (Complex B)
{
Complex temp;
temp.real=real + B.real;
temp.imag= imag + B.imag;
return temp;
}
void main ( )
{
Complex X, Y, Z;
X.Getdata( );
Y. getdata( );
Z= X.sum (Y);
Z.putdata( );
}
5
6
7
8
X Y Z
7
8
B
12
14
temp
Returning Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
Complex sum (Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”;
else
cout<<real<<imag<<“i”;
}
Complex Complex : : sum (Complex B)
{
Complex temp;
temp.real=real + B.real;
temp.imag= imag + B.imag;
return temp;
}
void main ( )
{
Complex X, Y, Z;
X.Getdata( );
Y. getdata( );
Z= X.sum (Y);
Z.putdata( );
}
5
6
7
8
12
14
X Y Z
7
8
B
12
14
temp
Returning Object
#include<iostream.h>
class Complex
{
float real, imag;
public:
void getdata( );
void putdata( );
Complex sum (Complex B);
};
void Complex : : getdata( )
{
cout<<“enter real part:”;
cin>>real;
cout<<“enter imaginary part:”;
cin>>imag;
}
void Complex : : putdata( )
{
if (imag>=0)
cout<<real<<“+”<<imag<<“i”
;
else
cout<<real<<imag<<“i”;
}
Complex Complex : : sum (Complex B)
{
Complex temp;
temp.real=real + B.real;
temp.imag= imag + B.imag;
return temp;
}
void main ( )
{
Complex X, Y, Z;
X.Getdata( );
Y. getdata( );
Z= X.sum (Y);
Z.putdata( );
}
12 + 14 i
5
6
7
8
12
14
X Y Z
7
8
B
12
14
temp

More Related Content

Similar to OBJECTS IN Object Oriented Programming .ppt

Writing native bindings to node.js in C++
Writing native bindings to node.js in C++Writing native bindings to node.js in C++
Writing native bindings to node.js in C++nsm.nikhil
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScriptJulie Iskander
 
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.pptDESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.pptAntoJoseph36
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)Anders Jönsson
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
Functional Core, Reactive Shell
Functional Core, Reactive ShellFunctional Core, Reactive Shell
Functional Core, Reactive ShellGiovanni Lodi
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUIAdam Lu
 
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018Codemotion
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarROHIT JAISWAR
 
Constructor in c++
Constructor in c++Constructor in c++
Constructor in c++Jay Patel
 
20070329 Java Programing Tips
20070329 Java Programing Tips20070329 Java Programing Tips
20070329 Java Programing TipsShingo Furuyama
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design PatternsStefano Fago
 

Similar to OBJECTS IN Object Oriented Programming .ppt (20)

C++ programs
C++ programsC++ programs
C++ programs
 
Writing native bindings to node.js in C++
Writing native bindings to node.js in C++Writing native bindings to node.js in C++
Writing native bindings to node.js in C++
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
Class and object C++.pptx
Class and object C++.pptxClass and object C++.pptx
Class and object C++.pptx
 
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.pptDESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)
 
662305 11
662305 11662305 11
662305 11
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
662305 10
662305 10662305 10
662305 10
 
Functional Core, Reactive Shell
Functional Core, Reactive ShellFunctional Core, Reactive Shell
Functional Core, Reactive Shell
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUI
 
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
 
Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
 
droidparts
droidpartsdroidparts
droidparts
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswar
 
Constructor in c++
Constructor in c++Constructor in c++
Constructor in c++
 
20070329 Java Programing Tips
20070329 Java Programing Tips20070329 Java Programing Tips
20070329 Java Programing Tips
 
Treinamento Qt básico - aula II
Treinamento Qt básico - aula IITreinamento Qt básico - aula II
Treinamento Qt básico - aula II
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
 
Day 1
Day 1Day 1
Day 1
 

Recently uploaded

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
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 ConsultingTechSoup
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 

Recently uploaded (20)

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
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
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 

OBJECTS IN Object Oriented Programming .ppt

  • 2. Objects  An object is an instance of a class.  An object is a class variable.  Is can be uniquely identified by its name.  Every object have a state which is represented by the values of its attributes. These state are changed by function which applied on the object.
  • 3. State identity and behavior of objects  Every object have identity , behavior and state.  The identity of object is defined by its name, every object is unique and can be differentiated from other objects.  The behavior of an object is represented by the functions which are defined in the object’s class. These function show the set of action for every objects.  The state of objects are referred by the data stored within the object at any time moment.
  • 4. Creating an object of a Class  Declaring a variable of a class type creates an object. You can have many variables of the same type (class).  Also known as Instantiation  Once an object of a certain class is instantiated, a new memory location is created for it to store its data members and code  You can instantiate many objects from a class type.  Ex) Circle c; Circle *c; Class item { ………. ,,,,,,,,,,,,, }x,y,z; We have to declared objects close to the place where they are needed because it makes easier to identify the objects.
  • 5. Object types  There are four types of objects 1. External (global )objects 1. This object have the existence throughout the lifetime of the program and having file –scope. 2. Automatic(local)objects 1. Persistent and visible only throughout the local scope in which they are created. 3. Static objects 1. Persistent throughout a program but only visible within their local scope. 4. Dynamic objects 1. Lifetime may be controlled within a particular scope.
  • 6. Memory Allocation of Object class student { int rollno; char name[20]; int marks; }; student s; rollno – 2 bytes name- 20 bytes marks- 2 bytes 24 bytes s
  • 7. Array of objects  The array of class type variable is known as array of object.  We can declare array of object as following way:- Class _name object [length]; Employee manager[3]; 1. We can use this array when calling a member function 2. Manager[i].put data(); 3. The array of object is stored in memory as a multi- dimensional array.
  • 8. Object as function arguments  This can be done in two ways:-  A copy of entire object is passed to the function.  ( pass by value)  Only the address of the object is transferred to the function. (pass by reference)
  • 9. ( pass by value)  A copy of the object is passed to the function, any changes made to the object inside the function do not affect the object used to call function.  When an address of object is passed, the called function works directly on the actual object used in the call. Means that any change made in side the function will reflect in the actual object. (pass by reference)
  • 10. Passing Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); void sum (Complex A, Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } void Complex : : sum ( complex A, complex B) { real = A.real + B.real; imag= A.imag + B.imag; } void main( ) { Complex X,Y,Z; X.getdata( ); Y.getdata( ); Z.sum(X,Y); Z.putdata( ); }
  • 11. Passing Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); void sum (Complex A, Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } void Complex : : sum ( Complex A, Complex B) { real = A.real + B.real; imag= A.imag + B.imag; } void main( ) { Complex X,Y,Z; X.getdata( ); Y.getdata( ); Z.sum(X,Y); Z.putdata( ); } X Y Z
  • 12. Passing Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); void sum (Complex A, Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } void Complex : : sum ( Complex A, Complex B) { real = A.real + B.real; imag= A.imag + B.imag; } void main( ) { Complex X,Y,Z; X.getdata( ); Y.getdata( ); Z.sum(X,Y); Z.putdata( ); } 5 6 7 8 X Y Z
  • 13. Passing Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); void sum (Complex A, Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } void Complex : : sum ( Complex A, Complex B) { real = A.real + B.real; imag= A.imag + B.imag; } void main( ) { Complex X,Y,Z; X.getdata( ); Y.getdata( ); Z.sum(X,Y); Z.putdata( ); } 5 6 7 8 X Y Z 5 6 7 8 A B
  • 14. Passing Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); void sum(Complex A, Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } void Complex : : sum ( Complex A, Complex B) { real = A.real + B.real; imag= A.imag + B.imag; } void main( ) { Complex X,Y,Z; X.getdata( ); Y.getdata( ); Z.sum(X,Y); Z.putdata( ); } 5 6 7 8 12 14 X Y Z 5 6 7 8 A B + + = =
  • 15. Passing Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); void sum (Complex A, Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } void complex : : sum ( Complex A, Complex B) { real = A.real + B.real; imag= A.imag + B.imag; } void main( ) { Complex X,Y,Z; X.getdata( ); Y.getdata( ); Z.sum(X,Y); Z.putdata( ); } 12 + 14 i 5 6 7 8 12 14 X Y Z 5 6 7 8 A B + + = =
  • 16. Returning Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); Complex sum (Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } Complex Complex : : sum (Complex B) { Complex temp; temp.real=real + B.real; temp.imag= imag + B.imag; return temp; } void main ( ) { Complex X, Y, Z; X.Getdata( ); Y. getdata( ); Z= X.sum (Y); Z.putdata( ); }
  • 17. Returning Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); Complex sum (Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } Complex Complex : : sum (Complex B) { Complex temp; temp.real=real + B.real; temp.imag= imag + B.imag; return temp; } void main ( ) { Complex X, Y, Z; X.Getdata( ); Y. getdata( ); Z= X.sum (Y); Z.putdata( ); } X Y Z
  • 18. Returning Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); Complex sum (Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } Complex Complex : : sum (Complex B) { Complex temp; temp.real=real + B.real; temp.imag= imag + B.imag; return temp; } void main ( ) { Complex X, Y, Z; X.Getdata( ); Y. getdata( ); Z= X.sum (Y); Z.putdata( ); } 5 6 7 8 X Y Z
  • 19. Returning Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); Complex sum (Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } Complex Complex : : sum (Complex B) { Complex temp; temp.real=real + B.real; temp.imag= imag + B.imag; return temp; } void main ( ) { Complex X, Y, Z; X.Getdata( ); Y. getdata( ); Z= X.sum (Y); Z.putdata( ); } 5 6 7 8 X Y Z 7 8 B
  • 20. Returning Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); Complex sum (Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } Complex Complex : : sum (Complex B) { Complex temp; temp.real=real + B.real; temp.imag= imag + B.imag; return temp; } void main ( ) { Complex X, Y, Z; X.Getdata( ); Y. getdata( ); Z= X.sum (Y); Z.putdata( ); } 5 6 7 8 X Y Z 7 8 B
  • 21. Returning Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); Complex sum (Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } Complex Complex : : sum (Complex B) { Complex temp; temp.real=real + B.real; temp.imag= imag + B.imag; return temp; } void main ( ) { Complex X, Y, Z; X.Getdata( ); Y. getdata( ); Z= X.sum (Y); Z.putdata( ); } 5 6 7 8 X Y Z 7 8 B 12 14 temp
  • 22. Returning Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); Complex sum (Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } Complex Complex : : sum (Complex B) { Complex temp; temp.real=real + B.real; temp.imag= imag + B.imag; return temp; } void main ( ) { Complex X, Y, Z; X.Getdata( ); Y. getdata( ); Z= X.sum (Y); Z.putdata( ); } 5 6 7 8 X Y Z 7 8 B 12 14 temp
  • 23. Returning Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); Complex sum (Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i”; else cout<<real<<imag<<“i”; } Complex Complex : : sum (Complex B) { Complex temp; temp.real=real + B.real; temp.imag= imag + B.imag; return temp; } void main ( ) { Complex X, Y, Z; X.Getdata( ); Y. getdata( ); Z= X.sum (Y); Z.putdata( ); } 5 6 7 8 12 14 X Y Z 7 8 B 12 14 temp
  • 24. Returning Object #include<iostream.h> class Complex { float real, imag; public: void getdata( ); void putdata( ); Complex sum (Complex B); }; void Complex : : getdata( ) { cout<<“enter real part:”; cin>>real; cout<<“enter imaginary part:”; cin>>imag; } void Complex : : putdata( ) { if (imag>=0) cout<<real<<“+”<<imag<<“i” ; else cout<<real<<imag<<“i”; } Complex Complex : : sum (Complex B) { Complex temp; temp.real=real + B.real; temp.imag= imag + B.imag; return temp; } void main ( ) { Complex X, Y, Z; X.Getdata( ); Y. getdata( ); Z= X.sum (Y); Z.putdata( ); } 12 + 14 i 5 6 7 8 12 14 X Y Z 7 8 B 12 14 temp