Answer Posted / qapoo
A function is declared virtual in base class when u are
having same functions in both base and derived classes and
you want to access both the functions with same function
call and its done using base class pointer.
e.g
class base
{
public:
void show(){cout<<"hi"};
};
class derived:pubic base
{
public:
void show(){cout<<"bye";}
};
int main()
{
base *ptr;
base b;
derived d;
ptr=&b;
ptr->show();//base class fn is called
ptr=&d;
ptr->show();//derived class fn is called
return 0;
}
| Is This Answer Correct ? | 7 Yes | 3 No |
Post New Answer View All Answers
How to use CMutex, CSemaphore in VC++ MFC
Is this job good for future? can do this job post grduate student?
write a code for this. serial_number contained in the header of the file will be read , if this serial number is less than a previous serial number within a successfully processed file, or is the same as another serial number within a successfully processed file, or if the field contains anything other than 7 digits, then the file must error with the reason ‘Invalid SERIAL_NUMBER’.
write a programe to calculate the simple intrest and compund intrest using by function overlading
to find out the minimum of two integer number of two different classes using friend function
What is polymorphism what are the different types of polymorphism?
What does sksksk mean in text slang?
Can private class be inherited?
write a C++ program for booking using constructor and destructor.
What is the difference between procedural programming and oops?
Why is polymorphism used?
What is for loop and its syntax?
Will I be able to get a picture in D drive to the c++ program? If so, help me out?
What is polymorphism in oops with example?
Explain the concepts involved in Object Oriented programming.