What are uses of virtual function in c++??
need of virtual function
@manoj katari thank u😊😊
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.
welcome back 😊 hope to see you at level 16 soon best luck👍👍
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.
@anisha ...dude..I expect a like storm tooo
to rope in runtime polymorphism benefits to your source code.. hope u like the 'like storm'
@anisha... babe.... I came back to sololearn after 6 months...thanks for the warmth...
@anisha thanks mate.. btw you are from which place in India?
In simple language: A virtual function is used when we have to override the member function of our base class for our derived classes
it saves the memory