Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Discard qualifiers

Reply
Thread Tools

Discard qualifiers

 
 
john
Guest
Posts: n/a
 
      01-13-2010
Hi,
I'm trying to sort a vector using
sort(corelist.begin(),corelist.end());
so I've provided a method to overload the < operator in the file, like
so, but it isn't a class member and the code which uses it is in
another file containing a class which inherits from this class:

bool operator< ( const Core& a, const Core& b) {
return a.getdistance() < b.getdistance();

}

Only problem is I get a const discard qualifiers error, which seems
very annoying. It seems to make me choose whether I want to hide my
code's variables or have them const. Removing the const seems to allow
the program to compile but there are a lot of errors (top line of
which shown below). getdistance just returns a double and I'm using
gcc. I haven't got a == operator in the code, but think I may possibly
need one.

Any help would be gratefully received

/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:
In function 'void std:artial_sort(_RandomAccessIterator,
_RandomAccessIterator, _RandomAccessIterator) [with
_RandomAccessIterator = __gnu_cxx::__normal_iterator<Core*,
std::vector<Core, std::allocator<Core> > >]':
 
Reply With Quote
 
 
 
 
Ben Pfaff
Guest
Posts: n/a
 
      01-13-2010
john <(E-Mail Removed)> writes:

> I'm trying to sort a vector using
> sort(corelist.begin(),corelist.end());
> so I've provided a method to overload the < operator in the file, like
> so, but it isn't a class member and the code which uses it is in
> another file containing a class which inherits from this class:


You are likely to get better responses to C++ questions in
comp.lang.c++.
--
Ben Pfaff
http://benpfaff.org
 
Reply With Quote
 
 
 
 
Seebs
Guest
Posts: n/a
 
      01-13-2010
On 2010-01-13, john <(E-Mail Removed)> wrote:
> bool operator< ( const Core& a, const Core& b) {


You might want comp.lang.c++.

Alternatively, I could just point out that this is a syntax error and
won't compile, and that's probably your problem.

Your call.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
 
Reply With Quote
 
Phil Carmody
Guest
Posts: n/a
 
      01-14-2010
Ben Pfaff <(E-Mail Removed)> writes:
> john <(E-Mail Removed)> writes:
>
>> I'm trying to sort a vector using
>> sort(corelist.begin(),corelist.end());
>> so I've provided a method to overload the < operator in the file, like
>> so, but it isn't a class member and the code which uses it is in
>> another file containing a class which inherits from this class:

>
> You are likely to get better responses to C++ questions in
> comp.lang.c++.


You lose.

Please evolve a defence mechanism against such completely
obvious trolls.
c.f. http://bytes.com/topic/c/answers/698...ard-qualifiers
dating back to 2007.

--
Any true emperor never needs to wear clothes. -- Devany on r.a.s.f1
 
Reply With Quote
 
Ben Pfaff
Guest
Posts: n/a
 
      01-14-2010
Phil Carmody <(E-Mail Removed)> writes:

> Ben Pfaff <(E-Mail Removed)> writes:
>> john <(E-Mail Removed)> writes:
>>
>>> I'm trying to sort a vector using
>>> sort(corelist.begin(),corelist.end());
>>> so I've provided a method to overload the < operator in the file, like
>>> so, but it isn't a class member and the code which uses it is in
>>> another file containing a class which inherits from this class:

>>
>> You are likely to get better responses to C++ questions in
>> comp.lang.c++.

>
> Please evolve a defence mechanism against such completely
> obvious trolls.
> c.f. http://bytes.com/topic/c/answers/698...ard-qualifiers
> dating back to 2007.


I'm not going to spend more time searching for a reason to call
an article a troll than I would spend writing up a completely
reasonable answer to it.
--
Ben Pfaff
http://benpfaff.org
 
Reply With Quote
 
Phil Carmody
Guest
Posts: n/a
 
      01-14-2010
Ben Pfaff <(E-Mail Removed)> writes:
> Phil Carmody <(E-Mail Removed)> writes:
>
>> Ben Pfaff <(E-Mail Removed)> writes:
>>> john <(E-Mail Removed)> writes:
>>>
>>>> I'm trying to sort a vector using
>>>> sort(corelist.begin(),corelist.end());
>>>> so I've provided a method to overload the < operator in the file, like
>>>> so, but it isn't a class member and the code which uses it is in
>>>> another file containing a class which inherits from this class:
>>>
>>> You are likely to get better responses to C++ questions in
>>> comp.lang.c++.

>>
>> Please evolve a defence mechanism against such completely
>> obvious trolls.
>> c.f. http://bytes.com/topic/c/answers/698...ard-qualifiers
>> dating back to 2007.

>
> I'm not going to spend more time searching for a reason to call
> an article a troll than I would spend writing up a completely
> reasonable answer to it.


So what? I did not suggest that you spend any time *searching* for
a reason to *call* an article a troll. I suggested that you evolve
an ability to detect such completely obvious trolls without needing
to perform a search, and that once you've so detected them, there's
no need for any response at all.

Phil
--
Any true emperor never needs to wear clothes. -- Devany on r.a.s.f1
 
Reply With Quote
 
Ben Pfaff
Guest
Posts: n/a
 
      01-14-2010
Phil Carmody <(E-Mail Removed)> writes:

> Ben Pfaff <(E-Mail Removed)> writes:
>> Phil Carmody <(E-Mail Removed)> writes:
>>> Please evolve a defence mechanism against such completely
>>> obvious trolls.

>>
>> I'm not going to spend more time searching for a reason to call
>> an article a troll than I would spend writing up a completely
>> reasonable answer to it.

>
> So what? I did not suggest that you spend any time *searching* for
> a reason to *call* an article a troll. I suggested that you evolve
> an ability to detect such completely obvious trolls without needing
> to perform a search, and that once you've so detected them, there's
> no need for any response at all.


I don't know how you tell the difference between an article
carelessly posted to the wrong newsgroup and a troll. To me, the
article resembled the former more than the latter.
--
Ben Pfaff
http://benpfaff.org
 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      01-15-2010
On 14 Jan, 22:30, Phil Carmody <(E-Mail Removed)>
wrote:
> Ben Pfaff <(E-Mail Removed)> writes:
> > Phil Carmody <(E-Mail Removed)> writes:

>
> >> Ben Pfaff <(E-Mail Removed)> writes:
> >>> john <(E-Mail Removed)> writes:

>
> >>>> I'm trying to sort a vector using
> >>>> * * * * sort(corelist.begin(),corelist.end());
> >>>> so I've provided a method to overload the < operator in the file, like
> >>>> so, but it isn't a class member and the code which uses it is in
> >>>> another file containing a class which inherits from this class:

>
> >>> You are likely to get better responses to C++ questions in
> >>> comp.lang.c++.

>
> >> Please evolve a defence mechanism against such completely
> >> obvious trolls.
> >> c.f.http://bytes.com/topic/c/answers/698...ard-qualifiers
> >> dating back to 2007.

>
> > I'm not going to spend more time searching for a reason to call
> > an article a troll than I would spend writing up a completely
> > reasonable answer to it.

>
> So what? I did not suggest that you spend any time *searching* for
> a reason to *call* an article a troll. I suggested that you evolve
> an ability to detect such completely obvious trolls without needing
> to perform a search,


how?

> and that once you've so detected them, there's
> no need for any response at all.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Discard qualifiers Jim C++ 2 08-24-2007 07:12 PM
why does my overloaded operator discard qualifiers gobis C++ 4 01-06-2006 02:30 PM
Test message, please discard Liangg.4124@schwarzschild.mcgill.ca Microsoft Certification 0 10-26-2004 04:38 AM
Starting up some profiles give a pop-up for working online or offline.How to discard that? Dirk BERTH Firefox 1 08-26-2004 06:49 AM
How can I silently discard packets ? phil~~ Cisco 6 11-13-2003 01:02 PM



Advertisments