473,241 Members | 1,616 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

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 6529
weaknessforcats
9,208 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

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

Similar topics

7
by: Alex Vinokur | last post by:
Hello, Here is some program with virtual constructors. Is there any difference between * clone1() vs. clone2() * create1() vs. create2() ? It seems that it should be.
2
by: franklini | last post by:
hello people i. can anybody help me, i dont know what is wrong with this class. it has something to do with the me trying to override the input output stream. if i dont override it, it works fine....
15
by: Susan Baker | last post by:
Hello everybody, I'm new to C++ (I have some C background). I've read up on this topic a few times but it just dosen't seem to be sinking in. 1. Whats the difference between overloading and...
2
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a...
6
by: Bern McCarty | last post by:
I'm trying to use the VS 2005 March Tech Preview and am trying to adjust some MC++ to the new C++/CLI syntax. I got a little hung up when I encountered the below error. Certainly my...
13
by: ctor | last post by:
Hi, I'm experiencing an annoying issue. Here is a simplified idea of what I am trying to do. Inclusion guards aren't shown for readability. I hope this isn't too confusing; I don't think a...
8
by: Alex Vinokur | last post by:
Here is a code from http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.8 -------------------------------------- class Shape { public: virtual ~Shape() { } // A...
3
by: kikazaru | last post by:
Is it possible to return covariant types for virtual methods inherited from a base class using virtual inheritance? I've constructed an example below, which has the following structure: Shape...
4
by: Rahul | last post by:
Hi Everyone, I understand that the constructors can't be virtual and parashift has the following example, to have an workaround for the constructors to be virtual, class Shape { public:...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.