473,386 Members | 1,621 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,386 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 6544
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.