如何给引用类型的参数指定默认值
怎么给引用类型的参数指定默认值?
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
------解决方案--------------------
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
------解决方案--------------------
关于自己是否适合编程的很简单的测试:
在报纸或杂志上随便找一段约1000字的文章,在Word中输入一遍。输完后再参考下面答案:
A里面有10处以上文字或标点错误
B里面没有文字或标点错误并敢为此跟人打赌
C里面没有文字或标点错误并且字体和排版完全与原稿一致
D打印在半透明的纸上和原稿重叠在一起检查一模一样,且自我感觉很有成就感
A不适合编程(理由:打字准确度偏低、粗心大意)
B初级程序员(理由:打字准确度很高、认真细致、自信、理解全角半角概念)
C高级程序员(理由:在B的基础上理解字体和排版也是电脑打印的重要因素、但相比D还不够偏执、精益求精、结果可验证)
D软件项目经理(理由:能针对项目给出令人信服的细致到极点的需求说明和典型测试用例。用户几乎挑不出毛病。专业!)
如果想从A变成B的话,到我的资源http://zhao4zhong1.download.****.net/里面下载“适合程序员的键盘练习”
------解决方案--------------------
楼主激动了
- C/C++ code
#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
------解决方案--------------------
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
------解决方案--------------------
关于自己是否适合编程的很简单的测试:
在报纸或杂志上随便找一段约1000字的文章,在Word中输入一遍。输完后再参考下面答案:
A里面有10处以上文字或标点错误
B里面没有文字或标点错误并敢为此跟人打赌
C里面没有文字或标点错误并且字体和排版完全与原稿一致
D打印在半透明的纸上和原稿重叠在一起检查一模一样,且自我感觉很有成就感
A不适合编程(理由:打字准确度偏低、粗心大意)
B初级程序员(理由:打字准确度很高、认真细致、自信、理解全角半角概念)
C高级程序员(理由:在B的基础上理解字体和排版也是电脑打印的重要因素、但相比D还不够偏执、精益求精、结果可验证)
D软件项目经理(理由:能针对项目给出令人信服的细致到极点的需求说明和典型测试用例。用户几乎挑不出毛病。专业!)
如果想从A变成B的话,到我的资源http://zhao4zhong1.download.****.net/里面下载“适合程序员的键盘练习”
------解决方案--------------------
楼主激动了