"mark" <[EMAIL PROTECTED]> writes:
> As far as I understand, the const keyword, without defining the Data
> member of the Matrix class to be "mutable", should not allow me to do
> that.
Correct. The following code demonstrates this to be true:
struct A {
A& operator=(const A& rhs) {
if (&rhs != this) {
delete this->Data;
this->Data = rhs.Data;
rhs.Data = 0;
}
return *this;
}
int *Data;
};
$ g++ -dumpversion
3.3.3
$ g++ -c junk.cc
junk.cc: In member function `A& A::operator=(const A&)':
junk.cc:6: error: assignment of data-member `A::Data' in read-only structure
> But it compiles ?!
Well, you never showed us what the complete definition of 'class
Matrix' is, so there is no way for us to tell why it compiles.
> Is this a "hidden" feature of g++ or am I
> misunderstanding things again?
I don't think there is a "hidden" feature (you can test your version
with my tiny example above). Something else must be at play here.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
_______________________________________________
Help-gplusplus mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gplusplus