Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Overloading the < operator

Posted on 2000-04-28
3
Medium Priority
?
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 400 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

597 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