Why do we use virtual functions?
Answers were Sorted based on User's Feedback
Answer / uma sankar pradhan
we use virtual functions to achive dynamic binding
Dynamic binding is establishing relation between the
function call and function definition at run time
| Is This Answer Correct ? | 22 Yes | 2 No |
Answer / bijal
The virtual function can be allowed in base classes only.
The functions markd Virtual will only be overridable in
derieved classes.
If i m having a function in base class that shud come in
derieved class but i want it to have different behaviour.
This can only be acheived only if base class function is
virtual function.
| Is This Answer Correct ? | 23 Yes | 8 No |
A pure virtual member function is a member function that the
base class forces derived classes to
provide. Normally these member functions have no
implementation. Pure virtual functions are
equated to zero.
class Shape { public: virtual void draw() = 0; };
| Is This Answer Correct ? | 8 Yes | 4 No |
Answer / mona kawale
when there are two same classes in derived and base class then at the tym of running programm compiler get confuse about which function should b call first so it call derived class function automatically....but if we wrote base class function as virtual function then compiler will not get confuse.....
| Is This Answer Correct ? | 2 Yes | 0 No |
i ahve v low % in 12th n BSC which is aroun 50 coz science was imposed on me......nw m doin MCA n my aggregate in above 74%,what shud i say if asked about low previous percentage??????
Program to check whether a word is the first word of the sentence.
what is the diffrence between c# and c++
program for insertion ,deletion,sorting in double link list
What is memory leak and memory corruption?
What is virtual constructors/destructors?
Is following functions are said to be overloaded? int add(int a,int b) char *add(int a,int b)
Why is oop better than procedural?
Can a varargs method be overloaded?
What is difference between function overloading and overriding?
In which Scenario you will go for Interface or Abstract Class?
1 Answers InfoAxon Technologies,
how to create thread in java?
17 Answers IBM, Infosys, Wipro,