What are virtual functions?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / nikhil kapoor
The function which supports run time polymorphysm is called
virtual function...
Is This Answer Correct ? | 3 Yes | 2 No |
Explain the concept of abstracion and encapsulation with one example. What is the difference between them?
What is a friend function & its advantage?
How many types of access specifier in c# and vb.net?
WHEN A COPY CONSTER IS CALL ?
What are the types of abstraction?
what is the usage of clas templates
what is the definition of incapsulation
write knight tour problem which is present in datastructure
Is following functions are said to be overloaded? int add(int a,int b) char *add(int a,int b)
Why is object oriented programming so hard?
i am getting an of the type can not convert int to int *. to overcome this problem what we should do?
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)