:
int* const p;
... p. const int* .
void *, ( void * delete, -). , , delete ( , ), void * , . , ; delete dtor .
, const Test& int* p , int* const p, int const* p const int* p.
:
Test::Test(const Test& other)
{
*other.p = 123; // this is valid
other.p = NULL; // this is not valid
}
In other words, the address of the pointer is immutable, but the dot is not. I often came across a lot of confusion here regarding the constant of a member function and its effect on data elements that are pointers. Understanding this will give a little understanding regarding one of the reasons why we need a separation between the iterator and const_iterator.
source
share