Compiler Error C2555 (Windows CE 5.0)

Send Feedback

'function1' of 'class1' : overriding virtual function differs from
'class2::function2' only by return type or calling convention

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 solve this error, cast the return value after the virtual function has been called.

The following example shows ways this error might occur.

struct X
{
   virtual void func();
};
struct Y : X
{
   char func();  // error
};

Microsoft® eMbedded Visual C++® does not support overriding a virtual function with a return type that differs in any way from the overridden function. The eMbedded Visual C++ compiler does not support covariant return types.

For example, the following examples are not allowed in eMbedded Visual C++,

// Example 1 
class A { 
public: 
virtual A* func(); 
}; 

class B : public A { 
public: 
virtual B* func(); 
}; 

//Example 2 
class C { 
public: 
virtual A* func(); 
}; 
class D : public C { 
public: 
virtual B* func(); 
};

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.