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??

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the advantages of inheritance.

1142


What is an interface in oop?

1043


What is encapsulation selenium?

1002


Why is object oriented programming so hard?

1079


What is polymorphism give a real life example?

1032


given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy

2623


What are the benefits of interface?

1056


State what is encapsulation and friend function?

1257


What is the difference between inheritance and polymorphism?

1110


What is abstraction in oop with example?

1120


What is polymorphism in oop example?

1023


Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.

2193


What is this pointer in oop?

1065


How do you explain polymorphism?

1072


What is object and class in oops?

1065