Smart Pointer release() const : it can set the pointer to null with the keyword "const"?

Smart Pointer release() const : it can set the pointer to null with the keyword "const"?

Post by coal » Thu, 07 Sep 2006 23:53:40



In Smart Pointer class, we have a piece of code:

inline void release(void) const { if (mPtr) mPtr->release(); mPtr = 0;
}

It can set mPtr but it is still const?

Why could this work and why it can be compiled? We have used it for
years.

Thanks.

- C.
 
 
 

Smart Pointer release() const : it can set the pointer to null with the keyword "const"?

Post by coal » Thu, 07 Sep 2006 23:58:50

Yeah you guys are right, many thanks.

mPtr is mutable, I didn't notice that.

Sorry for that.


- C.

 
 
 

Smart Pointer release() const : it can set the pointer to null with the keyword "const"?

Post by Victor Baz » Fri, 08 Sep 2006 00:00:07


You already asked that, three hours ago. Is there something you
didn't understand in the answers given? Do you not know how to
see the responses you've got so far? (if so, fat chance getting
this this question to be answered...)

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask