468,484 Members | 2,046 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

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

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
1 5798
weaknessforcats
9,207 Expert Mod 8TB
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.

Similar topics

7 posts views Thread by Alex Vinokur | last post: by
2 posts views Thread by franklini | last post: by
15 posts views Thread by Susan Baker | last post: by
8 posts views Thread by Alex Vinokur | last post: by
3 posts views Thread by kikazaru | last post: by
4 posts views Thread by Rahul | last post: by
reply views Thread by NPC403 | last post: by
2 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.