Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Can anyone please explain runtime polymorphism with a real
time example??at what ciscumstances we go for it??



Can anyone please explain runtime polymorphism with a real time example??at what ciscumstances we ..

Answer / anumeet

Here is a program of run-time polymorphism.
#include <iostream.h>
#include <string.h>
class father {
char name[20];
public:
father(char *fname) // 1 argument constructor
{
strcpy(name,fname)
}
virtual void show()
{
cout<<"father's name: "<<name<<"\n";
}
};
class son : public father
{
char name[20];
public:
son(char *sname,char *fname): father(fname)
{
strcpy(name,sname);
}
void show()
{
cout<<"son name: "<<sname<<"\n";
}
};
void main()
{
father *fp;
father f1("emraan");
fp=&f1;
fp->show();
son s1("kangana","emraan");
fp=&s1;
fp->show();
}




Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More OOPS Interview Questions

How to deploy web appliction in web logic ?

1 Answers   Unisys,


What is coupling in oops?

0 Answers  


Write a program to find out the number of palindromes in a sentence.

1 Answers   TCS,


swapping program does not use third variable

5 Answers   TCS,


What do you mean by Encapsulation?

0 Answers   Ittiam Systems,


write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).

0 Answers  


Out of 4 concepts, which 3 C++ Follow?

1 Answers   TCS,


what is use to destroy an object? illustrate.

5 Answers   TCS,


What is encapsulation in oop?

0 Answers  


what is polymorphism?

4 Answers  


What is polymorphism? Explain with an example.

48 Answers  


what is the virtual function overhead, and what is it used for ? i hope i can get and appropriate answers, thanks a lot....

6 Answers  


Categories