const_cast.cpp
来自「《C/C++程序员实用大全》配套代码,适用初学C++的人员。」· C++ 代码 · 共 22 行
CPP
22 行
#include <stdio.h>
class c {
public:
int j;
c(void) {j=10;}
};
void PrintInt(const c* Object)
{
c* New = const_cast<c*> (Object);
New->j +=5;
printf("%d\n", New->j);
}
void main(void)
{
const c Sample;
PrintInt(&Sample);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?