Wednesday, March 25, 2009

what is the difference between pure and virtual pure function C#?

When a function is virtual it can have a function body. If you want to overload that function you can, but you don't have to, which is probably what you want in most cases of inheritance.

Pure virtual functions have no body and MUST be overloaded. You cannot create an instance of a class with a pure virtual function, so something else has to inherit from it and overload all pure virtual functions. This is generally what is done for Interface Inheritance, where the interface class is just a bunch of pure virtual functions and all the actual code is in classes that inherit it.

No comments: