error C2664: “countChar”: 不能将参数 1 从“char [20]”转换为“std::string &”

来源:互联网 发布:ae软件下载 编辑:程序博客网 时间:2024/05/17 21:46
size_t countChar( string& str,char ch){cout<<str;return 1;}int main(void){     char buffer[20]; char c; cin>>c>>buffer; cout<<countChar(buffer,c);}

编译后就会出现该错误:

原因:类型转换失败,参数类型转换,不能讲str绑定在临时对象上面,详细请见博客:


http://blog.csdn.net/lujiandong1/article/details/41799959

0 0
原创粉丝点击