SlideShare ist ein Scribd-Unternehmen logo
1 von 42
PolymorphismPolymorphism
By
Nilesh Dalvi
Lecturer, Patkar-Varde College.Lecturer, Patkar-Varde College.
http://www.slideshare.net/nileshdalvi01
Object oriented ProgrammingObject oriented Programming
with C++with C++
Polymorphism
• Polymorphism is the technique in which
various forms of a single function can be
defined and shared by various objects to
perform the operation.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Polymorphism
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer
• A pointer is a memory variable that stores a
memory address. Pointers can have any
name that is legal for other variables and it
is declared in the same fashion like other
variables but it is always denoted by ‘*’
operator.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer declaration
• Syntax:
data-type * pointer-mane;
• For example:
• int *x; //integer pointer, holds
//address of any integer variable.
• float *f; //float pointer, stores
//address of any float variable.
• char *y; //character pointer, stores
//address of any character variable.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer declaration & initialization
int *ptr; //declaration.
int a;
ptr = &a; //initialization.
• ptr contains the address of a.
• We can also declare pointer variable to point
to another pointer,
int a, *ptr1, *ptr2;
ptr1 = &a;
ptr2 = &ptr1;
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
• We can manipulate the pointer with
indirection operator i.e. ‘*’ is also known as
deference operator.
• Dereferencing a pointer allows us to get the
content of the memory location.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Manipulation of Pointer
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Manipulation of Pointer
#include <iostream>
using namespace std;
int main()
{
int a = 10;
int *ptr;
ptr = &a;
cout <<"nDereferencing :: "<< *ptr <<endl;
*ptr = *ptr + a;
cout << a;
return 0;
}
• A pointer can be incremented(++) or
decremented(--).
• Any integer can be added to or subtracted
from a pointer.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer Expressions and Arithmetic:
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer Expressions and Arithmetic:
#include <iostream>
using namespace std;
int main()
{
int num [] = {56, 75, 22, 18, 90};
int *ptr;
ptr = &num[0]; // ptr = num;
cout << *ptr <<endl;
ptr++;
cout << *ptr <<endl;
ptr--;
cout << *ptr <<endl;
ptr = ptr + 2;
cout << *ptr <<endl;
ptr = ptr - 1;
cout << *ptr <<endl;
ptr += 3;
cout << *ptr <<endl;
ptr -=2;
cout << *ptr <<endl;
return 0;
}
• Pointer objects are useful in creating objects
at run-time.
• We can also use an object pointer to access
the public members of an object.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer to objects
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer to objects
#include <iostream>
using namespace std;
class item
{
int code;
float price;
public:
void getdata(int a, float b)
{
code = a;
price = b;
}
void show (void)
{
cout << code <<endl;
cout << price <<endl;
}
};
Pointer to objects
• We can also write ,
int main()
{
item x;
x.getdata(100, 75.6);
x.show();
item *ptr = &x;
ptr -> getdata(100, 75.6);
ptr ->show();
return 0;
}
(*ptr).show();//*ptr is an alias of x
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
• We can also create objects using pointers
and new operator as follows:
• Statements allocates enough memory for
data members in the objects structure.
• We can create array of objects using
pointers,
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer to objects
Item *ptr = new item;
Item *ptr = new item[10];
• Pointers can be declared to point base or
derived classes.
• Pointers to object of base class are type-
compatible with pointers to object of
derived class.
• Base class pointer can point to objects of
base and derived class.
• Pointer to base class object can point to
objects of derived classes whereas a pointer
to derived class object cannot point to
objects of base class.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer to derived classes
Fig: Type-compatibility of base and derived class
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer to derived classes
• If B is a base class and D is a derived class from B,
then a pointer declared as a pointer to B can also
be pointer to D.
B *ptr;
B b;
D d;
ptr = &b;
• We can also write,
ptr = &d;
• Here, we can access only those members which are
inherited from B and not the member that
originally belonging to D.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer to derived classes
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer to derived classes
#include <iostream>
using namespace std;
class B
{
public:
int b;
void show()
{
cout << "b = " << b <<endl;
}
};
class D : public B
{
public:
int d;
void show()
{
cout << "d = " << d <<endl;
}
};
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer to derived classes
int main()
{
B *bptr;
B bobj;
bptr = &bobj;
bptr -> b = 100;
bptr ->show ();
D dobj;
bptr = &dobj;
bptr -> b = 200;
bptr ->show ();
D *dptr;
dptr = &dobj;
dptr -> d = 300;
dptr ->show ();
return 0;
}
Output:
b = 100
b = 200
d = 300
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer to derived classes
#include <iostream>
using namespace std;
class Polygon
{
protected:
int width, height;
public:
void set_values (int a, int b)
{ width=a; height=b; }
};
class Rectangle: public Polygon
{
public:
int area()
{ return width*height; }
};
class Triangle: public Polygon
{
public:
int area()
{ return width*height/2; }
};
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Pointer to derived classes
int main ()
{
Rectangle rect;
Triangle trgl;
Polygon * ppoly1 = &rect;
Polygon * ppoly2 = &trgl;
ppoly1->set_values (4,5);
ppoly2->set_values (4,5);
Rectangle *rec = &rect;
cout << rec->area() << 'n';
cout << trgl.area() << 'n';
return 0;
}
• If there are member functions with same
name in base class and derived class, virtual
functions gives programmer capability to
call member function of different class by a
same function call depending upon different
context.
• This feature in C++ programming is known
as polymorphism which is one of the
important feature of OOP.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Virtual functions
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Virtual functions
#include <iostream>
using namespace std;
class B
{
public:
void display()
{ cout<<"Content of base class.n"; }
};
class D : public B
{
public:
void display()
{ cout<<"Content of derived class.n"; }
};
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Virtual functions
int main()
{
B *b = new B;
D d;
b->display();
b = &d; /* Address of object d in pointer variable */
b->display();
return 0;
}
Output:
Content of base class.
Content of base class.
• If you want to execute the member function
of derived class then, you can declare
display() in the base class virtual which
makes that function existing in appearance
only but, you can't call that function.
• In order to make a function virtual, you have
to add keyword virtual in front of a function.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Virtual functions
• The virtual functions should not be static
and must be member of a class.
• A virtual function may be declared as friend
for another class. Object pointer can access
virtual functions.
• Constructors cannot be declared as a virtual,
but destructor can be declared as virtual.
• The virtual function must be defined in
public section of the class. It is also possible
to define the virtual function outside the
class.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Rules for virtual functions
• It is also possible to return a value from
virtual function like other functions.
• The prototype of virtual functions in base
and derived classes should be exactly the
same.
– In case of mismatch, the compiler neglects the
virtual function mechanism and treats them as
overloaded functions.
• Arithmetic operation cannot be used with
base class pointer.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Rules for virtual functions
• If base class contains virtual function and if
the same function is not redefined in the
derived classes in that base class function is
invoked.
• The operator keyword used for operator
overloading also supports virtual
mechanism.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Rules for virtual functions
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Virtual functions
#include <iostream>
using namespace std;
class B
{
public:
virtual void display() /* Virtual function */
{ cout<<"Content of base class.n"; }
};
class D1 : public B
{
public:
void display()
{ cout<<"Content of first derived class.n"; }
};
class D2 : public B
{
public:
void display()
{ cout<<"Content of second derived class.n"; }
};
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Virtual functions
int main()
{
B *b = new B;
D1 d1;
D2 d2;
/* b->display(); // You cannot use this code here
because the function of base class is virtual. */
b = &d1;
b->display(); /* calls display() of class derived D1 */
b = &d2;
b->display(); /* calls display() of class derived D2 */
return 0;
}
Output:
Content of first derived class.
Content of second derived class.
• In above program, display( ) function of two
different classes are called with same code
which is one of the example of
polymorphism in C++ programming using
virtual functions.
• Remember, run-time polymorphism is
achieved only when a virtual function is
accessed through a pointer to the base class.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Virtual functions
• If expression =0 is added to a virtual
function then, that function is becomes pure
virtual function.
• Note that, adding =0 to virtual function does
not assign value, it simply indicates the
virtual function is a pure function.
• If a base class contains at least one virtual
function then, that class is known as
abstract class.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Declaration of a Abstract Class
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Abstract Class
#include <iostream>
using namespace std;
class Shape /* Abstract class */
{
protected:
float l;
public:
void get_data() /* Note: this function is not virtual. */
{
cin>>l;
}
virtual float area() = 0; /* Pure virtual function */
};
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Abstract Class
class Square : public Shape
{
public:
float area()
{ return l*l; }
};
class Circle : public Shape
{
public:
float area()
{ return 3.14*l*l; }
};
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Abstract Class
Output :
Enter length to calculate area of a square: 2
Area of square: 4
Enter radius to calcuate area of a circle:3
Area of circle: 28.26
int main()
{
Shape *ptr;
Square s;
Circle c;
ptr = &s;
cout<<"Enter length to calculate area of a square: ";
ptr -> get_data();
cout<<"Area of square: "<<ptr ->area();
ptr = &c;
cout<<"nEnter radius to calcuate area of a circle:";
ptr -> get_data();
cout<<"Area of circle: "<<ptr ->area();
return 0;
}
• Consider a book-shop which sells both
books and videos-tapes.
• We can create media that stores the title
and price of a publication.
• We can then create two derived classes, one
for storing the number of pages in a book
and another for storing playing time of a
tape.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Implementation in practice
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Implementation in practice
Fig: class hierarchy for book shop
mediamedia
tapetapebookbook
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Abstract Class
#include <iostream>
using namespace std;
class media /* Abstract class */
{
protected:
char *title;
double price;
public:
media(char *s, double p)
{
title = new char [strlen(s)+1];
strcpy (title, s);
price = p;
}
virtual void display() = 0; /* Pure virtual function */
};
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Abstract Class
class book : public media
{
int pages;
public:
book(char *s, double p, int pg):media(s,p)
{
pages = pg;
}
void display()
{
cout << "Book details :" << endl;
cout << "Title : "<< title << endl;
cout << "Price : "<< price << endl;
cout << "No of pages: "<< pages << endl;
}
};
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Abstract Class
class tape : public media
{
int duration;
public:
tape(char *s, double p, int dr):media(s,p)
{
duration = dr;
}
void display()
{
cout << "Tape details :" << endl;
cout << "Title : "<< title << endl;
cout << "Price : "<< price << endl;
cout << "Duration: "<< duration << endl;
}
};
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Abstract Class
int main()
{
media *ptr;
book b("My Life....",12.22,200);
tape t("Tech Talks..",56.23,80);
ptr = &b;
ptr -> display ();
ptr = &t;
ptr -> display ();
return 0;
}
Output :
Book details :
Title : My Life....
Price : 12.22
No of pages: 200
Tape details :
Title : Tech Talks..
Price : 56.23
Duration: 80
Polymorphism

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

File handling
File handlingFile handling
File handling
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Packages
PackagesPackages
Packages
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Constructors in C++
Constructors in C++Constructors in C++
Constructors in C++
 
Difference between C++ and Java
Difference between C++ and JavaDifference between C++ and Java
Difference between C++ and Java
 
OOP C++
OOP C++OOP C++
OOP C++
 
Operators and Expressions in Java
Operators and Expressions in JavaOperators and Expressions in Java
Operators and Expressions in Java
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
file handling c++
file handling c++file handling c++
file handling c++
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programming
 
concept of oops
concept of oopsconcept of oops
concept of oops
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
Types of Constructor in C++
Types of Constructor in C++Types of Constructor in C++
Types of Constructor in C++
 
Java Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingJava Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overriding
 
Exception handling c++
Exception handling c++Exception handling c++
Exception handling c++
 

Andere mochten auch

Andere mochten auch (13)

14. Linked List
14. Linked List14. Linked List
14. Linked List
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
 
7. Multithreading
7. Multithreading7. Multithreading
7. Multithreading
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
11. Arrays
11. Arrays11. Arrays
11. Arrays
 
10. Introduction to Datastructure
10. Introduction to Datastructure10. Introduction to Datastructure
10. Introduction to Datastructure
 
13. Queue
13. Queue13. Queue
13. Queue
 
12. Stack
12. Stack12. Stack
12. Stack
 
Strings
StringsStrings
Strings
 
Constructors & destructors
Constructors & destructorsConstructors & destructors
Constructors & destructors
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
polymorphism
polymorphism polymorphism
polymorphism
 
Constructor and destructor in c++
Constructor and destructor in c++Constructor and destructor in c++
Constructor and destructor in c++
 

Ähnlich wie Polymorphism

3. Data types and Variables
3. Data types and Variables3. Data types and Variables
3. Data types and VariablesNilesh Dalvi
 
Pooja Sharma , BCA Third Year
Pooja Sharma , BCA Third YearPooja Sharma , BCA Third Year
Pooja Sharma , BCA Third YearDezyneecole
 
Daksh Sharma ,BCA 2nd Year
Daksh  Sharma ,BCA 2nd YearDaksh  Sharma ,BCA 2nd Year
Daksh Sharma ,BCA 2nd Yeardezyneecole
 
Intro-OOP-PPT- an introduction to the su
Intro-OOP-PPT- an introduction to the suIntro-OOP-PPT- an introduction to the su
Intro-OOP-PPT- an introduction to the suImranAliQureshi3
 
OOP PPT 1.pptx
OOP PPT 1.pptxOOP PPT 1.pptx
OOP PPT 1.pptxlathass5
 
Virtual function
Virtual functionVirtual function
Virtual functionsdrhr
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...Sagar Verma
 
Object oriented programming 2
Object oriented programming 2Object oriented programming 2
Object oriented programming 2Aadil Ansari
 
C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01Zafor Iqbal
 
classes & objects.ppt
classes & objects.pptclasses & objects.ppt
classes & objects.pptBArulmozhi
 
Lecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxLecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxShaownRoy1
 
Pooja Sharma ,BCA 2nd Year
Pooja Sharma ,BCA 2nd YearPooja Sharma ,BCA 2nd Year
Pooja Sharma ,BCA 2nd Yeardezyneecole
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Abu Saleh
 
Object Oriented Programming Constructors & Destructors
Object Oriented Programming  Constructors &  DestructorsObject Oriented Programming  Constructors &  Destructors
Object Oriented Programming Constructors & Destructorsanitashinde33
 
Module 1 - Programming Fundamentals.pptx
Module 1 - Programming Fundamentals.pptxModule 1 - Programming Fundamentals.pptx
Module 1 - Programming Fundamentals.pptxGaneshRaghu4
 

Ähnlich wie Polymorphism (20)

3. Data types and Variables
3. Data types and Variables3. Data types and Variables
3. Data types and Variables
 
Pooja Sharma , BCA Third Year
Pooja Sharma , BCA Third YearPooja Sharma , BCA Third Year
Pooja Sharma , BCA Third Year
 
Daksh Sharma ,BCA 2nd Year
Daksh  Sharma ,BCA 2nd YearDaksh  Sharma ,BCA 2nd Year
Daksh Sharma ,BCA 2nd Year
 
Intro-OOP-PPT- an introduction to the su
Intro-OOP-PPT- an introduction to the suIntro-OOP-PPT- an introduction to the su
Intro-OOP-PPT- an introduction to the su
 
OOP PPT 1.pptx
OOP PPT 1.pptxOOP PPT 1.pptx
OOP PPT 1.pptx
 
Virtual function
Virtual functionVirtual function
Virtual function
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
 
Object oriented programming 2
Object oriented programming 2Object oriented programming 2
Object oriented programming 2
 
C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01
 
classes & objects.ppt
classes & objects.pptclasses & objects.ppt
classes & objects.ppt
 
Lecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxLecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptx
 
Oops lecture 1
Oops lecture 1Oops lecture 1
Oops lecture 1
 
Pooja Sharma ,BCA 2nd Year
Pooja Sharma ,BCA 2nd YearPooja Sharma ,BCA 2nd Year
Pooja Sharma ,BCA 2nd Year
 
advance-dart.pptx
advance-dart.pptxadvance-dart.pptx
advance-dart.pptx
 
OOP in java
OOP in javaOOP in java
OOP in java
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
 
Object Oriented Programming Constructors & Destructors
Object Oriented Programming  Constructors &  DestructorsObject Oriented Programming  Constructors &  Destructors
Object Oriented Programming Constructors & Destructors
 
Lecture02
Lecture02Lecture02
Lecture02
 
Module 1 - Programming Fundamentals.pptx
Module 1 - Programming Fundamentals.pptxModule 1 - Programming Fundamentals.pptx
Module 1 - Programming Fundamentals.pptx
 

Mehr von Nilesh Dalvi

9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in javaNilesh Dalvi
 
6. Exception Handling
6. Exception Handling6. Exception Handling
6. Exception HandlingNilesh Dalvi
 
5. Inheritances, Packages and Intefaces
5. Inheritances, Packages and Intefaces5. Inheritances, Packages and Intefaces
5. Inheritances, Packages and IntefacesNilesh Dalvi
 
1. Overview of Java
1. Overview of Java1. Overview of Java
1. Overview of JavaNilesh Dalvi
 
Standard Template Library
Standard Template LibraryStandard Template Library
Standard Template LibraryNilesh Dalvi
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cppNilesh Dalvi
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops conceptsNilesh Dalvi
 

Mehr von Nilesh Dalvi (10)

9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 
8. String
8. String8. String
8. String
 
6. Exception Handling
6. Exception Handling6. Exception Handling
6. Exception Handling
 
5. Inheritances, Packages and Intefaces
5. Inheritances, Packages and Intefaces5. Inheritances, Packages and Intefaces
5. Inheritances, Packages and Intefaces
 
2. Basics of Java
2. Basics of Java2. Basics of Java
2. Basics of Java
 
1. Overview of Java
1. Overview of Java1. Overview of Java
1. Overview of Java
 
Standard Template Library
Standard Template LibraryStandard Template Library
Standard Template Library
 
Templates
TemplatesTemplates
Templates
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
 

Kürzlich hochgeladen

Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1GloryAnnCastre1
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleCeline George
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 

Kürzlich hochgeladen (20)

Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP Module
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 

Polymorphism

  • 1. PolymorphismPolymorphism By Nilesh Dalvi Lecturer, Patkar-Varde College.Lecturer, Patkar-Varde College. http://www.slideshare.net/nileshdalvi01 Object oriented ProgrammingObject oriented Programming with C++with C++
  • 2. Polymorphism • Polymorphism is the technique in which various forms of a single function can be defined and shared by various objects to perform the operation. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 4. Pointer • A pointer is a memory variable that stores a memory address. Pointers can have any name that is legal for other variables and it is declared in the same fashion like other variables but it is always denoted by ‘*’ operator. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 5. Pointer declaration • Syntax: data-type * pointer-mane; • For example: • int *x; //integer pointer, holds //address of any integer variable. • float *f; //float pointer, stores //address of any float variable. • char *y; //character pointer, stores //address of any character variable. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 6. Pointer declaration & initialization int *ptr; //declaration. int a; ptr = &a; //initialization. • ptr contains the address of a. • We can also declare pointer variable to point to another pointer, int a, *ptr1, *ptr2; ptr1 = &a; ptr2 = &ptr1; Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 7. • We can manipulate the pointer with indirection operator i.e. ‘*’ is also known as deference operator. • Dereferencing a pointer allows us to get the content of the memory location. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Manipulation of Pointer
  • 8. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Manipulation of Pointer #include <iostream> using namespace std; int main() { int a = 10; int *ptr; ptr = &a; cout <<"nDereferencing :: "<< *ptr <<endl; *ptr = *ptr + a; cout << a; return 0; }
  • 9. • A pointer can be incremented(++) or decremented(--). • Any integer can be added to or subtracted from a pointer. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Pointer Expressions and Arithmetic:
  • 10. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Pointer Expressions and Arithmetic: #include <iostream> using namespace std; int main() { int num [] = {56, 75, 22, 18, 90}; int *ptr; ptr = &num[0]; // ptr = num; cout << *ptr <<endl; ptr++; cout << *ptr <<endl; ptr--; cout << *ptr <<endl; ptr = ptr + 2; cout << *ptr <<endl; ptr = ptr - 1; cout << *ptr <<endl; ptr += 3; cout << *ptr <<endl; ptr -=2; cout << *ptr <<endl; return 0; }
  • 11. • Pointer objects are useful in creating objects at run-time. • We can also use an object pointer to access the public members of an object. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Pointer to objects
  • 12. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Pointer to objects #include <iostream> using namespace std; class item { int code; float price; public: void getdata(int a, float b) { code = a; price = b; } void show (void) { cout << code <<endl; cout << price <<endl; } };
  • 13. Pointer to objects • We can also write , int main() { item x; x.getdata(100, 75.6); x.show(); item *ptr = &x; ptr -> getdata(100, 75.6); ptr ->show(); return 0; } (*ptr).show();//*ptr is an alias of x Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 14. • We can also create objects using pointers and new operator as follows: • Statements allocates enough memory for data members in the objects structure. • We can create array of objects using pointers, Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Pointer to objects Item *ptr = new item; Item *ptr = new item[10];
  • 15. • Pointers can be declared to point base or derived classes. • Pointers to object of base class are type- compatible with pointers to object of derived class. • Base class pointer can point to objects of base and derived class. • Pointer to base class object can point to objects of derived classes whereas a pointer to derived class object cannot point to objects of base class. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Pointer to derived classes
  • 16. Fig: Type-compatibility of base and derived class Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Pointer to derived classes
  • 17. • If B is a base class and D is a derived class from B, then a pointer declared as a pointer to B can also be pointer to D. B *ptr; B b; D d; ptr = &b; • We can also write, ptr = &d; • Here, we can access only those members which are inherited from B and not the member that originally belonging to D. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Pointer to derived classes
  • 18. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Pointer to derived classes #include <iostream> using namespace std; class B { public: int b; void show() { cout << "b = " << b <<endl; } }; class D : public B { public: int d; void show() { cout << "d = " << d <<endl; } };
  • 19. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Pointer to derived classes int main() { B *bptr; B bobj; bptr = &bobj; bptr -> b = 100; bptr ->show (); D dobj; bptr = &dobj; bptr -> b = 200; bptr ->show (); D *dptr; dptr = &dobj; dptr -> d = 300; dptr ->show (); return 0; } Output: b = 100 b = 200 d = 300
  • 20. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Pointer to derived classes #include <iostream> using namespace std; class Polygon { protected: int width, height; public: void set_values (int a, int b) { width=a; height=b; } }; class Rectangle: public Polygon { public: int area() { return width*height; } }; class Triangle: public Polygon { public: int area() { return width*height/2; } };
  • 21. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Pointer to derived classes int main () { Rectangle rect; Triangle trgl; Polygon * ppoly1 = &rect; Polygon * ppoly2 = &trgl; ppoly1->set_values (4,5); ppoly2->set_values (4,5); Rectangle *rec = &rect; cout << rec->area() << 'n'; cout << trgl.area() << 'n'; return 0; }
  • 22. • If there are member functions with same name in base class and derived class, virtual functions gives programmer capability to call member function of different class by a same function call depending upon different context. • This feature in C++ programming is known as polymorphism which is one of the important feature of OOP. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Virtual functions
  • 23. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Virtual functions #include <iostream> using namespace std; class B { public: void display() { cout<<"Content of base class.n"; } }; class D : public B { public: void display() { cout<<"Content of derived class.n"; } };
  • 24. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Virtual functions int main() { B *b = new B; D d; b->display(); b = &d; /* Address of object d in pointer variable */ b->display(); return 0; } Output: Content of base class. Content of base class.
  • 25. • If you want to execute the member function of derived class then, you can declare display() in the base class virtual which makes that function existing in appearance only but, you can't call that function. • In order to make a function virtual, you have to add keyword virtual in front of a function. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Virtual functions
  • 26. • The virtual functions should not be static and must be member of a class. • A virtual function may be declared as friend for another class. Object pointer can access virtual functions. • Constructors cannot be declared as a virtual, but destructor can be declared as virtual. • The virtual function must be defined in public section of the class. It is also possible to define the virtual function outside the class. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Rules for virtual functions
  • 27. • It is also possible to return a value from virtual function like other functions. • The prototype of virtual functions in base and derived classes should be exactly the same. – In case of mismatch, the compiler neglects the virtual function mechanism and treats them as overloaded functions. • Arithmetic operation cannot be used with base class pointer. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Rules for virtual functions
  • 28. • If base class contains virtual function and if the same function is not redefined in the derived classes in that base class function is invoked. • The operator keyword used for operator overloading also supports virtual mechanism. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Rules for virtual functions
  • 29. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Virtual functions #include <iostream> using namespace std; class B { public: virtual void display() /* Virtual function */ { cout<<"Content of base class.n"; } }; class D1 : public B { public: void display() { cout<<"Content of first derived class.n"; } }; class D2 : public B { public: void display() { cout<<"Content of second derived class.n"; } };
  • 30. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Virtual functions int main() { B *b = new B; D1 d1; D2 d2; /* b->display(); // You cannot use this code here because the function of base class is virtual. */ b = &d1; b->display(); /* calls display() of class derived D1 */ b = &d2; b->display(); /* calls display() of class derived D2 */ return 0; } Output: Content of first derived class. Content of second derived class.
  • 31. • In above program, display( ) function of two different classes are called with same code which is one of the example of polymorphism in C++ programming using virtual functions. • Remember, run-time polymorphism is achieved only when a virtual function is accessed through a pointer to the base class. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Virtual functions
  • 32. • If expression =0 is added to a virtual function then, that function is becomes pure virtual function. • Note that, adding =0 to virtual function does not assign value, it simply indicates the virtual function is a pure function. • If a base class contains at least one virtual function then, that class is known as abstract class. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Declaration of a Abstract Class
  • 33. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Abstract Class #include <iostream> using namespace std; class Shape /* Abstract class */ { protected: float l; public: void get_data() /* Note: this function is not virtual. */ { cin>>l; } virtual float area() = 0; /* Pure virtual function */ };
  • 34. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Abstract Class class Square : public Shape { public: float area() { return l*l; } }; class Circle : public Shape { public: float area() { return 3.14*l*l; } };
  • 35. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Abstract Class Output : Enter length to calculate area of a square: 2 Area of square: 4 Enter radius to calcuate area of a circle:3 Area of circle: 28.26 int main() { Shape *ptr; Square s; Circle c; ptr = &s; cout<<"Enter length to calculate area of a square: "; ptr -> get_data(); cout<<"Area of square: "<<ptr ->area(); ptr = &c; cout<<"nEnter radius to calcuate area of a circle:"; ptr -> get_data(); cout<<"Area of circle: "<<ptr ->area(); return 0; }
  • 36. • Consider a book-shop which sells both books and videos-tapes. • We can create media that stores the title and price of a publication. • We can then create two derived classes, one for storing the number of pages in a book and another for storing playing time of a tape. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Implementation in practice
  • 37. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Implementation in practice Fig: class hierarchy for book shop mediamedia tapetapebookbook
  • 38. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Abstract Class #include <iostream> using namespace std; class media /* Abstract class */ { protected: char *title; double price; public: media(char *s, double p) { title = new char [strlen(s)+1]; strcpy (title, s); price = p; } virtual void display() = 0; /* Pure virtual function */ };
  • 39. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Abstract Class class book : public media { int pages; public: book(char *s, double p, int pg):media(s,p) { pages = pg; } void display() { cout << "Book details :" << endl; cout << "Title : "<< title << endl; cout << "Price : "<< price << endl; cout << "No of pages: "<< pages << endl; } };
  • 40. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Abstract Class class tape : public media { int duration; public: tape(char *s, double p, int dr):media(s,p) { duration = dr; } void display() { cout << "Tape details :" << endl; cout << "Title : "<< title << endl; cout << "Price : "<< price << endl; cout << "Duration: "<< duration << endl; } };
  • 41. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Abstract Class int main() { media *ptr; book b("My Life....",12.22,200); tape t("Tech Talks..",56.23,80); ptr = &b; ptr -> display (); ptr = &t; ptr -> display (); return 0; } Output : Book details : Title : My Life.... Price : 12.22 No of pages: 200 Tape details : Title : Tech Talks.. Price : 56.23 Duration: 80