http://yun.baidu.com/share/link?shareid=1806708168&uk=3190641435&third=0
补充:
1 函数不能返回另一个函数或者内置数组类型,但可以返回指向函数的指针,或者指向数组元素的指针的指针。
2
// 用const才能直接用字符串字面值来调用函数
int find_char(const string &s, char check) {
int i = 0;
while (i != s.size() && s[i] != check) {
i++;
}
return i;
}
cout << find_char("hello world", 'o') << endl;
3 事实上,c++程序员倾向于使用需要处理的元素的迭代器来传递容器
void print(vector<int>::iterator beg,
vector<int>::iterator end) {
while (beg != end) {
cout << *beg << endl;
beg++;
}
}
4 通过引用传递数组,数组的大小会成为形参和实参类型的一部,编译器会检查。
Created by stary_yan.
Copyright © 2016 stary_yan. All rights reserved.