Can we have a private virtual method ?
Answer Posted / sriram
We can have the private virtual method. But it can be
accessed only through the derived class not through the
base class.
class A
{
private:
virtual void fun() { std::cout << "A::fun" <<
std::endl; }
};
class B : public A
{
public:
virtual void fun() { std::cout << "B::fun" <<
std::endl; }
};
int main(int argc, char* argv[])
{
A* pa = new A();
((B*)(pa))->fun();
}
Output : A::fun
Is This Answer Correct ? | 4 Yes | 3 No |
Post New Answer View All Answers
What is the example of polymorphism?
What is polymorphism in oops?
What does and I oop mean?
what is graphics
What is the difference between abstraction and polymorphism?
Why do we use polymorphism?
What is the types of inheritance?
Why polymorphism is used in oops?
What are the features of oop?
what are the different types of qualifier in java?
What is a null tree?
Can a varargs method be overloaded?
hi all..i want to know oops concepts clearly can any1 explain??
What is variable example?
Write a program to sort the number with different sorts in one program ??