On Wednesday 17 April 2002 8:21 pm, Lars Gullik Bjønnes wrote: > Angus Leeming <[EMAIL PROTECTED]> writes: > | I'm clearly confused when it comes to "const" and member pointers. > | > | See the little code snippet below. If I compile it, I get the error: > | > | cxx: Error: trial.C, line 23: (that is, in the const_method) > | the object has type qualifiers that are not compatible with the member > | function > | func(ob()); > > I get this message: > > testsome.C: In member function `void Wrapper::const_method() const': > testsome.C:23: passing `const Wrapper' as `this' argument of `FL_OBJECT* > Wrapper::ob()' discards qualifiers > > > Looks perfectly sane too me. > > all methods that const_method calls must be const. > > if I make ob() const everything just compiles.
I know this. I'm just trying to improve my understanding. The interesting thing is that if I have a class class wrapper { public: wrapper(FL_OBJECT * ob) : ob_(ob) {} /* public methods */ private: FL_OBJECT * const ob_; }; then ALL the methods can be const, because we never change the pointer, just what it points to. class wrapper { ... void setGeometry(uint x, uint y, uint w, uint h) CONST; }; Now that strikes me as being just wierd. My question is now, should I make all methods const, or rather use my intuition about which are const and which aren't. This makes more sense to me: class wrapper { ... void setGeometry(uint x, uint y, uint w, uint h); uint x() const; }; Do you have any opinions about which way I should go? Angus