Hi,
What is the difference between Fridge function and Virtual function?
Thank you.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jun 3, 2012, 8:01 AM
But, joking apart, can you think what Ankur might be referring to here? May be there's some word that sounds a bit like fridge which can be applied to functions.
FroglegPosted Jun 3, 2012, 5:26 AM
A virtual function is where you sit thinking of drinking a beer
VulpesPosted Jun 3, 2012, 5:18 AM
Googling it has also yielded a blank.
However, a virtual function (or method as they usually called in C#) is a function which can be overridden in sub-classes which want to provide their own implementation of it.
At runtime, the actual type of the object (not necessarily its compile-time type) determines which version of the virtual method to call. For example, if SomeMethod is a virtual function of the Parent class which is over-ridden in the Child sub-class:
Parent p = new Parent();
p.SomeMethod(); // calls Parent's version
p = new Child();
p.SomeMethod(); // calls Child's version because 'p' refers to a Child object, not a Parent object