注册 登录
编程论坛 C++教室

字符串指针求助

dltanglin 发布于 2010-08-04 10:44, 538 次点击
const char * filename;
filename = "boy.jpg";
为什么会显示expected constructor,destructor,or type conversion before "=" token?
3 回复
#2
mxs8102010-08-04 10:47
const 类型的指针只能在初始化的时候赋值吧~~~
#3
pangding2010-08-05 00:18
不会吧,感觉没什么错误。

版主说的那个是指针常量,不是指向常量的指针。
#4
zgxyz20082010-08-05 09:58
如果const位于星号的左侧,则const就是用来修饰指针所指向的变量,即指针指向为常量。个人觉得对于字符串是否使用const修饰左侧,没有明显的区别...
1