|
|
||||
|
|
Const-cast TypecastConst casts are only available in C++. Const casts are used to strip the const-ness or volatile-ness from a variable. Const casts should be used sparingly; one example of a valid use of a const-cast is to strip the const-ness of a pointer to pass it into a function when you are certain the function will not modify the variable but the function designer did not specify the input as const.const_cast<<type>>(<value>);This example casts a const pointer to a non-const pointer to pass into a function: void func(char *); const char *x = "abcd"; func(const_cast<char *>(x)); ----- |
|
||