问:const_cast强制类型转换是是否会把传入的原始指针改变? 答:不会,会产生并返回一个新的去const的指针
#include int main() { int ary[4] = { 1,2,3,4 }; for (int i = 0; i < 4; i++) std::cout << ary[i] << "t"; std::cout << std::endl; const int*c_ptr = ary; int *ptr = const_cast(c_ptr); /
上一篇 算法基础(三)——STL容器的简单使用
下一篇 Python 使用 logging 模块添加多输出并设置不同的日志等级
版权所有 ©2023-2025 051e.com
ICP备案号:京ICP备12030808号