Can anyone please explain runtime polymorphism with a real
time example??at what ciscumstances we go for it??
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 |
Write on signed and unsigned integers and give three (3) examples each
Give an example where we have to specifically use C programming language and C++ programming language cannot be used?
Write an operator overloading program to Overload ‘>’ operator so as to find greater among two instances of the class.
4. What do you mean by a prototype? Define analysis prototype
Can main method override?
What is a template?
what are three tenets of object orinted Systems?Why they call like that ? Please answer me. Advance thanks.
What does and I oop mean?
What is overriding vs overloading?
There are two base class B1,B2 and there is one class D which is derived from both classes, Explain the flow of calling constructors and destructors when an object of derived class is instantiated.
What is object and example?
Give two or more real cenario of virtual function and vertual object