MESSAGE
DATE | 2008-08-30 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] Workshop C++ errors
|
error: passing `const Weight' as `this' argument of `float Weight::wgt()' discards qualifiers
seems to be some sort of standard error format that I'm not understanding.
I have code that looks like this
header file
class Weight{ public: Weight(); explicit Weight(float wgt); Weight(float wgt, const string &unit); Weight(string); float operator=(const float w ); Weight& operator=(const Weight&); //doesn't work - assignment needs a single argument ////float operator=(const float wgt, const string &unit);
inline float wgt(){ return wgt_; }; float wgt(const float weight); float wgt(const float weight, const string &unit); float wgt(const string &descr);
definition or class file
Weight& Weight::operator=(const Weight &fweight) { //No choice but to hope it is in kilograms unit_ = "kg"; wgt_ = fweight.wgt(); return this; } }
it all looks legal to me.
Ruben Safir
-- http://www.mrbrklyn.com - Interesting Stuff http://www.nylxs.com - Leadership Development in Free Software
So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998
http://fairuse.nylxs.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
"Yeah - I write Free Software...so SUE ME"
"The tremendous problem we face is that we are becoming sharecroppers to our own cultural heritage -- we need the ability to participate in our own society."
"> I'm an engineer. I choose the best tool for the job, politics be damned.< You must be a stupid engineer then, because politcs and technology have been attached at the hip since the 1st dynasty in Ancient Egypt. I guess you missed that one."
© Copyright for the Digital Millennium
|
|