473,507 Members | 3,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C2662 Error

Hi,

This is a member function I wrote:
bool MyClass::operator==(const MyClass &a_suaDateTime) const
{
return (m_oleDateTime == a_suaDateTime.DateTime()); //m_oleDateTime
an MFC class
}

I get this error message:
error C2662: 'DateTime' : cannot convert 'this' pointer from 'const
class CSuaDateTime' to 'class CSuaDateTime &'
Conversion loses qualifiers

Why???
Thanks!
Jul 22 '05 #1
3 2473
du*****@012.net.il wrote:
Hi,

This is a member function I wrote:
bool MyClass::operator==(const MyClass &a_suaDateTime) const
{
return (m_oleDateTime == a_suaDateTime.DateTime()); //m_oleDateTime
an MFC class
}

I get this error message:
error C2662: 'DateTime' : cannot convert 'this' pointer from 'const
class CSuaDateTime' to 'class CSuaDateTime &'
Conversion loses qualifiers

Why???


Apparently, 'DateTime' is a non-const function. Don't call it, just
compare the values of 'm_oleDateTime' members:

return m_oleDateTime == a_suaDateTime.m_oleDateTime;

V
Jul 22 '05 #2
du*****@012.net.il wrote:
Hi,

This is a member function I wrote:
bool MyClass::operator==(const MyClass &a_suaDateTime) const
{
return (m_oleDateTime == a_suaDateTime.DateTime()); //m_oleDateTime
an MFC class
}

I get this error message:
error C2662: 'DateTime' : cannot convert 'this' pointer from 'const
class CSuaDateTime' to 'class CSuaDateTime &'
Conversion loses qualifiers

Why???
Thanks!


Can't be sure of the definition of your class, but my guess is that

MyClass::DateTime() is not defined as a const method.
Jul 22 '05 #3
Hi Victor and Red!

You were both right! I forgot to set DateTime() as const method!

Thanks a lot!
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4359
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
5
16218
by: Tony Wright | last post by:
Hi, I am having a problem installing an msi for a web site. The error message I am getting is: "The specified path 'http://mipdev05/features/Fas2' is unavailable. The Internet Information...
13
6572
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
4979
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
10
5884
by: dorkrawk | last post by:
I am having an issue with some VC++ I am writing. I have a struct and I'm trying to call a function from it from a function in another object. here is the struct.... struct JNI_Interface {...
3
15701
by: mishink7 | last post by:
i am getting this error error C2662: 'std::vector<_Ty>::push_back' : cannot convert 'this' pointer from 'const std::vector<_Ty>' to 'std::vector<_Ty> &' with and ...
1
1889
TheMan1
by: TheMan1 | last post by:
Hi, I'm making a simple program in C++. I have an object named TextReader, with a function GetString(), and I also have another object, TextWriter. Now when *TextWriter is called, it needs to...
2
19403
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
2897
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
7223
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
7110
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
7314
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,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.