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

More Related Content

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

C++ programs
C++ programsC++ programs
C++ programs
Mukund Gandrakota
 
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 JavaScript
Julie Iskander
 
Class and object C++.pptx
Class and object C++.pptxClass and object C++.pptx
Class and object C++.pptx
SantoshVarshney3
 
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
AntoJoseph36
 
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
 
662305 11
662305 11662305 11
662305 11
Nitigan Nakjuatong
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
Dmitry Sheiko
 
662305 10
662305 10662305 10
662305 10
Nitigan Nakjuatong
 
Functional Core, Reactive Shell
Functional Core, Reactive ShellFunctional Core, Reactive Shell
Functional Core, Reactive Shell
Giovanni Lodi
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUI
Adam 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 2018
Codemotion
 
Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
Dmitry Baranovskiy
 
droidparts
droidpartsdroidparts
droidparts
Droidcon Berlin
 
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
ROHIT 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 Tips
Shingo Furuyama
 
Treinamento Qt básico - aula II
Treinamento Qt básico - aula IITreinamento Qt básico - aula II
Treinamento Qt básico - aula II
Marcelo Barros de Almeida
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
Stefano Fago
 
Day 1
Day 1Day 1
Day 1
Pat Zearfoss
 
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 JavaScript
Julie 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.ppt
AntoJoseph36
 
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 Introduction
Dmitry Sheiko
 
Functional Core, Reactive Shell
Functional Core, Reactive ShellFunctional Core, Reactive Shell
Functional Core, Reactive Shell
Giovanni Lodi
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUI
Adam 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 2018
Codemotion
 
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
ROHIT 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 Tips
Shingo Furuyama
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
Stefano Fago
 

Recently uploaded (20)

How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.
MCH
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
Engage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdfEngage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdf
TechSoup
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
"Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules""Basics of Heterocyclic Compounds and Their Naming Rules"
"Basics of Heterocyclic Compounds and Their Naming Rules"
rupalinirmalbpharm
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.
MCH
 
Real GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for SuccessReal GitHub Copilot Exam Dumps for Success
Real GitHub Copilot Exam Dumps for Success
Mark Soia
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
Engage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdfEngage Donors Through Powerful Storytelling.pdf
Engage Donors Through Powerful Storytelling.pdf
TechSoup
 
Ad

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