C1390: Implicit virtual function

[INFORMATION]

Description

The 'virtual' keyword is needed only in the base class's declaration of the function; any subsequent declarations in derived classes are virtual by default.

Example
  class A{ //base class

  
   public:

  
    virtual void f(void){ glob=2; } //definition of a 

  
                                    //virtual function

  
  };

  
  class B : public A{ //derived class

  
   public:

  
    void f(void){ glob=3; } //overriding function

  
                            //IMPLICIT VIRTUAL FUNCTION

  
  };

  
Example2:
  class A{ // base class

  
   public:

  
    virtual void f(void){ glob=2; } //definition of a 

  
                                    //virtual function.

  
  };

  
  class B : public A{ //derived class

  
   public:

  
    virtual void f(void){ glob=3; } //overriding function:

  
                                    //'virtual' is not

  
                                    // necessary here

  
  };

  
Example3:
  class A{ //base class

  
   public:

  
    virtual void f(void){ glob=2; } //definition of a

  
                                    //virtual function.

  
  };

  
  class B : public A { //derived class

  
   public:

  
    void f(int a){ glob=3+a; } // not overriding function

  
  };

  
Tips

A derived class's version of a virtual function must have the same parameter list and return type as those of the base class. If these are different, the function is not considered a redefinition of the virtual function. A redefined virtual function cannot differ from the original only by the return type.