You have one base class virtual function how will call that
function from derived class?
Answers were Sorted based on User's Feedback
Answer / kalaivani
u can call the base class virtual fn,if it is declare as
public
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / narendra
class A
{
public:
virtual void fun()
{
cout<<"class A\n";
}
};
class B:public A
{
public:
virtual void fun()
{
cout<<"class B\n";
A::fun(); //calling base class virtual function.
}
};
Is This Answer Correct ? | 4 Yes | 2 No |
Answer / mazher
class B:A
{
public override void A_Func()
{
base.A_Func();
}
}
Is This Answer Correct ? | 1 Yes | 2 No |
What is polymorphism give a real life example?
What will happen when the following code is run: int x; while(x<100) { cout<<x; x++; } 1) The computer will output "0123...99" 2) The computer will output "0123...100" 3) The output is undefined
for example A,B,C,D are class all the 4 class contain one method who() but the method who() implementaion is differnet among each class. the relation among the 4 class are A is base class and is inherited by B and C.and from this two B and C where D is inherited. the question is i want to display the output who() method in all the classes(A,B,C,D)the output of who() method is diferrent amond all the class(A,B,C,D) ------A------ virtuval who(print a) override | | who(print b) B C override who(print c) | | -------D------ override who(print d)
Where You Can Use Interface in your Project
What do we mean by a hidden argument in a function?
What is difference between oop and pop?
Program to open a file with First argument
How many human genes are polymorphic?
What is class encapsulation?
what is the drawback of classical methods in oops?
What is class and object in oops?
what are the characteristics of oops?