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
What is the highest level of cohesion?
What exactly is polymorphism?
Can enum be null?
What is polymorphism and types?
What is object and class in oops?
What is the difference between abstraction and polymorphism?
Where is pseudocode used?
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).
What is interface? When and where is it used?
2. Give the different notations for the class.\
officer say me - i am offered to a smoking , then what can you say
why reinterpret cast is considered dangerous?
What is destructor oops?
What is encapsulation in oops?
Can abstract class have normal methods?