G
George2
Hello everyone,
In MSDN sample for const_cast,
http://msdn2.microsoft.com/en-us/library/bz6at95h(VS.80).aspx
There is a statement like this,
--------------------
On the line containing the const_cast, the data type of the this
pointer is const CCTest *. The const_cast operator changes the data
type of the this pointer to CCTest *
--------------------
I think in a const member function, like void printNumber() const, the
type of this pointer is const pointer to current type, so we use this
const_cast to remove its const properties.
For a non-const member function, I think this pointer should not be a
const pointer, right?
So, conclusion is,
1. in const member function, this pointer is a const pointer;
2. in non-const member function, this pointer is a non-const pointer.
Right?
thanks in advance,
George
In MSDN sample for const_cast,
http://msdn2.microsoft.com/en-us/library/bz6at95h(VS.80).aspx
There is a statement like this,
--------------------
On the line containing the const_cast, the data type of the this
pointer is const CCTest *. The const_cast operator changes the data
type of the this pointer to CCTest *
--------------------
I think in a const member function, like void printNumber() const, the
type of this pointer is const pointer to current type, so we use this
const_cast to remove its const properties.
For a non-const member function, I think this pointer should not be a
const pointer, right?
So, conclusion is,
1. in const member function, this pointer is a const pointer;
2. in non-const member function, this pointer is a non-const pointer.
Right?
thanks in advance,
George