Solved

Overloading the < operator

Posted on 2000-04-28
3
160 Views
Last Modified: 2010-04-02
I get some weird error message saying:

E:\vc++\Private\StarDist\CFlexPoint.h(53) : error C2662: 'Y' : cannot convert 'this' pointer from 'const class CFlexPoint' to 'class CFlexPoint &'

when I try to overload the < operator..

WHAT IS WRONG???
THIS IS KILLING ME!!!
0
Comment
Question by:lar_jens
3 Comments
 
LVL 5

Expert Comment

by:proskig
ID: 2760486
Please post your code for this operator and its definition
0
 
LVL 22

Accepted Solution

by:
nietod earned 100 total points
ID: 2760594
it sounds like you declated operator < to be a const function, which it usually is, by including a "const" after the function's parameters, like the final "const" in

bool SomeClass::operator <(const SomeClass &Rht) const;

That is fine, in fact usually prefereable, but it means that the object that the function is invoked for must be treated as a constant object.  If you try to change the object, or try to call a non-constant member function (one that doesn't hae this "const" at the end), then you will get this error.

How to go about fixing the problem depends on details you haven't provided.
0
 
LVL 1

Author Comment

by:lar_jens
ID: 2761908
Thank you..
I solved my problem, and got wiser..

Couldn't get better...
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now