-
what is polymorphism and how can I use it
in this situation?
-------------------------------------------------------------------------
Book is the root class Nativebool and ForeignBook derivated from it.
you want to enter a number from user.
if number is 1, you will create NativeBook object
else if number is 2, you will create ForeignBook Object; (Polymorphism)
int main()
{
Book *fptr; // you will point a object prefered by user
.
NativeBook tf(xxx,xxx,1997,60);
(1) tf.display();
ForeignBook ff(Brave,Michael Michiel,2002,95,English);
(2) ff.display();
Cout<<please give a number
(1) Native Book
(2) Foreign Book;
// You will code this area..
..
fptr=&ff; // if you enter 1 polymorphism
(3) fptr->display(); //
---------------------------------------------------------------------------
-
foreignbook ff, behave like nativebook bf. How can I do this in this situation.
-
Programming Sex-God
-
Popular pages
Recent additions