怎么给引用类型的参数指定默认值?
时间:2011-12-12
来源:互联网
C/C++ code
C:\Users\admin\Documents\1212.cpp|11|error: ISO C++ forbids declaration of 'stirng' with no type|
C:\Users\admin\Documents\1212.cpp|11|error: expected ',' or '...' before '&' token|
C:\Users\admin\Documents\1212.cpp||In function 'std::string make_plural(int, const std::string&, int)':|
C:\Users\admin\Documents\1212.cpp|13|error: 'ending' was not declared in this scope|
||=== Build finished: 3 errors, 0 warnings ===|
这个是用来求单词的复数形式,我想给ending指定一个默认的s
#include <iostream> #include <string> using namespace std; int main() { string make_plural(int t,const string &word,const string &ending="s"); string str="apple"; cout<<make_plural(1,str); return 0; } string make_plural(int t,const string &word,const stirng &ending="s") { return (t==1)? word:word+ending; }
C:\Users\admin\Documents\1212.cpp|11|error: ISO C++ forbids declaration of 'stirng' with no type|
C:\Users\admin\Documents\1212.cpp|11|error: expected ',' or '...' before '&' token|
C:\Users\admin\Documents\1212.cpp||In function 'std::string make_plural(int, const std::string&, int)':|
C:\Users\admin\Documents\1212.cpp|13|error: 'ending' was not declared in this scope|
||=== Build finished: 3 errors, 0 warnings ===|
这个是用来求单词的复数形式,我想给ending指定一个默认的s
作者: haolly 发布时间: 2011-12-12
string写错误了
string make_plural(int t,const string &word,const stirng &ending="s")
应为
string make_plural(int t,const string &word,const string &ending="s")
string make_plural(int t,const string &word,const stirng &ending="s")
应为
string make_plural(int t,const string &word,const string &ending="s")
作者: gameslq 发布时间: 2011-12-12
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28