+ 29
What are uses of virtual function in c++??
need of virtual function
11 odpowiedzi
+ 22
@manoj katari thank u😊😊
+ 23
Virtual functions ensure that the correct function is called for an object, regardless of the type of reference (or pointer) used for function call.They are mainly used to achieve Runtime polymorphism.Functions are declared with a virtual keyword in base class.The resolving of function call is done at Run-time.
+ 19
welcome back 😊 hope to see you at level 16 soon best luck👍👍
+ 18
Maharashtra
+ 8
For example you create a function in a base class, and you want to call that function in the base class to the derived classes, it is not possible to do that because you need to declare the function in the base class as a virtual function first, then you can call the function with the base class pointer. Hope this answer your question.
+ 8
@anisha ...dude..I expect a like storm tooo
+ 7
to rope in runtime polymorphism benefits to your source code.. hope u like the 'like storm'
+ 7
@anisha... babe.... I came back to sololearn after 6 months...thanks for the warmth...
+ 7
@anisha thanks mate.. btw you are from which place in India?
+ 1
In simple language:
A virtual function is used when we have to override the member function of our base class for our derived classes
- 6
it saves the memory