[C++]函数
2016-02-12 20:58
295 查看
http://yun.baidu.com/share/link?shareid=1806708168&uk=3190641435&third=0
补充:
1 函数不能返回另一个函数或者内置数组类型,但可以返回指向函数的指针,或者指向数组元素的指针的指针。
2
3 事实上,c++程序员倾向于使用需要处理的元素的迭代器来传递容器
4 通过引用传递数组,数组的大小会成为形参和实参类型的一部,编译器会检查。
Created by stary_yan.
Copyright © 2016 stary_yan. All rights reserved.
补充:
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.
相关文章推荐
- C++学习笔记2
- 第九章
- c++ 输入输出
- hdu2037 简单贪心
- [C++]标准库容器
- [C++]容器和算法
- c++ string 用法总结
- C++中cin、cin.get()、cin.getline()、getline()、gets()等
- Windows下pip安装包报错:Microsoft Visual C++ 9.0 is required Unable to find vcvarsall.bat
- C语言——数据类型,运算符,表达式
- C语言实现双向链表
- sum=2+5+8+11+14+…,输入正整数n,求sum的前n项和。
- 编制程序,输入n个整数(n从键盘输入,n>0),输出它们的偶数和。
- C语言调用mysql数据库API实现简单的mysql客户端的功能
- C++使用流进行输入输出
- C/C++ 文件读写
- 【C语言】C语言标识符
- 【C语言】C语言标识符
- 【C语言】C语言关键字
- 【C语言】外部函数和内部函数