Since I had a lot of ambiguity in my post, I will redo it. This is a problem I am encountering in a project which I am upgrading from a visual studio 6.0 environment to a visual studio 2012 environment.
I have a class which is derived from the followinh mfc class (CPropertyPage) which contains the following function. file is afxdlgs.h (mfc class)
class CPropertyPage : public CDialog
{
public:
virtual CPropertySheet *GetParentSheet();
}
I also still seem to have the problem after changing the forward declaration. Which was a result due to my bad formulation. So I have changed it back to it's original form.
The derived class looks like this. header
class CBankDefImportSheet;
class CBankDefImportAssignPage : public CPropertyPage
{
protected:
CBankDefImportSheet* GetParentSheet ();
}
in the cpp
#include "BankDefImportSheet.h"
CBankDefImportSheet* CBankDefImportAssignPage::GetParentSheet()
{
return (CBankDefImportSheet *)GetParent ();
}
furthermore the CBangDefImportSheet is
class CBankDefImportSheet : public CPropertySheet
{}
when I compile I get the C2555 error that the return type differs and is not covariant from CPropertyPage::GetParentSheet.
I have tried adding the header of CBankDefImportSheet but that did not solve it. I have also read a possibility of being able to cast after the return type, but unsure if that would solve it, furthermore unsure of how to do it in this case.
EDIT: After solving, post below was part of the problem, however, so was const correctness. Shame on me!
in the header it should be specified as
CBankDefImportSheet * GetParentSheet () const;
and furthermore in the cpp
CBankDefImportSheet * CBankDefImportAssignPage::GetParentSheet() const
{
return ((CBankDefImportSheet *)GetParent ());
}