Answer Posted / danish afzal
Virtual is important part of polymorphism,and if a function of a base class is virtual we can use or override it in drived classes.
class base
{
virtual void foo() const
{
cout << "danish B";
}
};
class derived1 :public base
{
void foo() const
{
cout << "danish D1";
}
};
class derived2 :public base
{
void foo() const
{
cout << "danish D2";
}
};
Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?
How to call a non virtual function in the derived class by using base class pointer
• What are the desirable attributes for memory managment?
What are two types of polymorphism?
What is object in oop?
How do you explain polymorphism?
What is inheritance and how many types of inheritance?
What is encapsulation in oops?
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
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.
How do you achieve polymorphism?
What are the benefits of oop?
write knight tour problem which is present in datastructure
Is oop better than procedural?
What is inheritance in simple words?