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

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
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
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
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
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 

Recently uploaded (20)

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
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🔝
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
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
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 

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