空指针访问成员函数
- C++中空指针也是可以调用成员函数的,但是也要注意有没有用到this指针
- 如果用到this指针,需要加以判断保证代码的健壮性
代码示例:
空指针调用函数
#define _CRT_SECURE_NO_DEPRECATE #define _CR
深度探索C++对象模型这本书还有提到C++类的成员变量指针和成员函数指针,虽然在实际开发中用的不多,但是还是
类的成员函数指针和普通的函数指针 在C++中是完全两个不同的东西今天偶然需要找了点资料才发现这个问题,写一个简单的例子
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M