刨根问底系列之C++ 类型转换挖掘(二)
里的memcpy函数。这种转换方式及其不安全,所以不推荐用。
const_cast 这种转换可以将常量转换为动态变量返回。
[cpp]
#include
#include
#include
using namespace std;
int main() {
const char* str = "hello,world";
try{
char* newStr = const_cast
(str);