Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual C++
C/C++ Build Errors
 Compiler Error C2555

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual C++ Concepts: Building a C/C++ Program
Compiler Error C2555

Error Message

' class1::function1': overriding virtual function return type differs and is not covariant from 'class2::function2'

A virtual function and a derived overriding function have identical parameter lists but different return types. An overriding function in a derived class cannot differ from a virtual function in a base class only by its return type.

To resolve this error, cast the return value after the virtual function has been called.

You may also see this error if you compile with /clr. For example, the Visual C++ equivalent to the following C# declaration:

Guid[] CheckSources(Guid sourceID, Guid[] carouselIDs);

is

Guid CheckSources(Guid sourceID, Guid carouselIDs[]) [];

For more information on C2555, see Knowledge Base article Q240862.

The following sample generates C2555:

// C2555.cpp
// compile with: /c
struct X {
   virtual void func();
};
struct Y : X {
   char func();  // C2555
   void func2();   // OK
};
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker