C/C++ Compiler (cl.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
C2555
                                             Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
     Compiler error C2555
 
     'class1::function1' : overriding virtual function differs from
     'class2::function2' only by return type
 
     The specified virtual function and a derived overriding function
     had identical parameter lists but different return types.
 
     An overriding function in a derived class cannot be redefined to
     differ only by its return type from a virtual function in a base
     class.
 
     A function in a derived class or structure overrides a virtual
     function in a base class only if their names, parameters, and
     return values are all identical. (If the functions have different
     parameters, then the compiler treats them as different functions
     and does not override the virtual function.)
 
     It may be necessary to cast the return value after the virtual
     function has been called.
 
     The following is an example of this error:
 
          struct X
          {
             virtual void func();
          };
 
          struct Y : X
          {
             char func();  // error
          };
                                    -♦-