Tuesday, 23 April 2013

What Is Pure Virtual Function? Why and When It Is Used?

If any virtual Function It Containing Signature with nobody, this is known as  Incomplete Function and  also known as Pure virtual Function.

In virtual function, the main disadvantage is wastage of code. This can overcome using Pure Virtual Functions.


Syntax: 

virtual Return Type Function_name()=0;

Pure virtual function also should be preceded by Virtual keyword, Zero should be assigned to function(represent incomplete function).

Pure Virtual Function always contained only Signature, but nobody parted.

Rules To Declared Pure Virtual function:


1. Every Pure virtual function should be declared in the public scope of Base class.

2. IF any class contained at-lest one pure virtual function that becomes abstract class, Every abstract class should  be inherited in at-least One Class.

3. Every pure virtual function of Base class should be declared in public scope of derived class with body part or without.

4. Pure Virtual Function always should be called using based class pointer Object.

5. If any class contained at-least one pure virtual function is known as obstruct class.

6. One class can contain any number of Pure virtual Function.



0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More