By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,911 Members | 1,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,911 IT Pros & Developers. It's quick & easy.

GetMenu': overriding virtual function return type differs and is not covariant from '

P: 2
Hi All,

i am using VS2008 and trying to port my previous application which is working fine in VS2003.
I am facing the following problem in this version(VS2008).. Please guide me how to solve this ..

error C2555: 'CGTDMenuBar::GetMenu': overriding virtual function return type differs and is not covariant from 'CWnd::GetMenu'

C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxwin.h(2245) : see declaration of 'CWnd::GetMenu'


Thanks in advance!!


Thanks & Regards
Garimella Srinivasu
Mar 14 '08 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
I don't believe VS2003 supported covariance. I think that started with VS2005.

Covariance in C++ when it comes to overriding virtual functions means that the return type of the overriding function can be different from the overriden function provided that the return type of the overriding function is lower (down) in the hierarchy.

For example:
Expand|Select|Wrap|Line Numbers
  1. class Shape
  2. {
  3.     public:
  4.       virtual Shape* Copy();
  5. };
  6. class Ellipse : public Shape
  7. {
  8.     public:
  9.        virtual Ellipse* Copy();  //OK. Ellipse covariant in Ellipse 
  10.                                                 //becuse it is lower in the hierarchy
  11.  
  12. };
  13. class Circle : public Ellipse
  14. {
  15. public:
  16.        virtual Shape* Copy();    //ERROR.  Shape not covariant in Circle
  17.                                                  //because it is higher in the hierarchy
  18. };
  19.  
You will have to check your MFC hierarchy to see what's going. Considering the age of MFC, I would not be surprised to find that it is incompatible with the ANS C++ standard. You may have to tweak the design.
Mar 14 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.