Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - declaration http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   Declaration
   A  virtual  function  is declared in the base class by  means  of  the
   virtual  keyword.  This  is  placed immediately to  the  left  of  the
   function return type. For example:
   class Temp
   {
   public:
   virtual int do();
   };

   The  virtual  keyword  is  only permitted  within  a  member  function
   declaration.

   It is not necessary to provide an instance of the virtual function  in
   the base class, provided this is indicated to the compiler. The syntax
   for declaring a virtual function which has no accompanying  definition
   is:

   class Temp
   {
   public:
   virtual int do() = 0;
   };
   This virtual function cannot be invoked by a base class object and  is
   known  as a pure virtual function. A base class with one or more  pure
   virtual functions cannot declare any objects and is often referred  to
   as an abstract class. If a class declares a virtual function, which is
   not  a  pure virtual function, it must provide a definition  for  that
   function,  even if it is empty. Abstract classes can only be  used  as
   base classes.


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson