Code:
class C {};
const C *a = new C;
C *b = const_cast
Neither of the other three new cast operators can modify the constness of an object.
Notes:
o It is undefined behaviour if the pointer is used to write on an constant object (an object declared as 'const').
o The 'const_cast' operator can also change the 'volatile' qualifier on a type.
No comments:
Post a Comment