Sort a Vector of Pointers to an object, based on objects properties

B

BobR

Salt_Peter wrote in message ...
For the record, the accessor i provided is and was constant.
std::string get() const;

In your boost example you did. In your first post (the progression I was
following), it was unspecified (but, worked fine once the const is applied.).
 
S

Salt_Peter

sorry; I must have missed that. Although I am learning; there is a LOT
to learn and I miss things in syntax.

Thanks again for all your amazing efforts.

You welcome. my pleasure.

Missing the const is ok - don't worry about that.
Whats important is to understand what the compiler is telling you.
Since the Directory parameter passed to the comparator function is a
constant pointer to a constant Directory, the GetName() member function
needs to be const because otherwise the compiler wouldn't be able to
*guarentee* that the Directory parameter(s) will *not* be modified by
GetName().

const == immutable (even by accident)

That compiler is actually quite smart. Its enforcing rules depending on
how you construct the class.
 
B

BobR

(e-mail address removed) wrote in message ...
Hurray!! And there was much rejoicing!!!

That was it! I needed that const!

OY! That was painful.

Sometimes 'painful' forces memory. Think you'll ever forget 'const' again?
Thank you all for your patience!


After all that, I hope you got a decent grade!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top