扫码关注官方订阅号
#include class father { public: char* name[16]; int money; father(char* name,int money); }; father::father(char*name,int money) { this->name=name; this->money=money; }
在vs2012中编写,倒数第二行指向name的的this下有红色浪线提示说“表达式必须是可修改的左值”,请问为什么不能这么写
光阴似箭催人老,日月如移越少年。
char* name[16] 是指针数组,而 father::father(char* name, int money) 的参数 name 是一个指针,当然不能直接赋值了。
可以写成 this -> name [0] = name;
不过我猜题主的原本意思肯定不是这个。
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
char* name[16] 是指针数组,而 father::father(char* name, int money) 的参数 name 是一个指针,当然不能直接赋值了。
可以写成 this -> name [0] = name;
不过我猜题主的原本意思肯定不是这个。