I m using visual studio. I was trying virtual function. I have one query.
when i used as
virtual void area(int*val)=0;
visual studio gave error as "cannot instantiate abstract class".
but if i used as
virtual void area(int*val){}
then it is working ok.
By using virtualvoid area(int*val)=0;, you are declaring it as "pure virtual", which means that the class for which it is declared is now implicitly defined to be abstract, and abstract classes can't be instantiated.
Any classes derived from this class NEED to define any pure virtual functions. If they do not, they will also become abstract.
Using the definition without "= 0" does not make the class abstract, which means that it can be instantiated.
What's interesting to note is that you can declare a pure virtual function that has a definition. To me that seems counter-intuitive, but the "feature" is there nonetheless.