using namespace std; 名称空间的概念
用来缓解复杂程序的组织问题;函数的名称相同,参数类型也相同(不能重载);解决办法就是将两个函数写在各自的名称空间里,然后就可以调用zhang3:funtcion()和lisi:function()这样的方式进行调用了
C++中使用流简化输入输出操作,标准输入输出流在头文件iostream中定义,存在于名称空间std中
template 模板
template<typename T> T sum(T* begin T* end){} --template模板
template<class T >
结构体struct
很多的情况都和class相似,于class不同的是,结构体包含的函数默认是public,而不是private
#include<iostream>
#include<algorithm>
using namespace std;
struct Point {
int x, y;
Point(int x = 0, int y = 0) : x(x), y(y) {}
};
Point operator + (const Point& A, const Point& B) {
return Point(A.x + B.x, A.y + B.y);
}
ostream& operator << (ostream& out, const Point& p) {
out << "(" << p.x << "," << p.y << ")";
return out;
}
template <typename T

本文介绍了C++的基础知识,包括名称空间的作用,如何使用流进行输入输出,模板的使用,结构体与类的区别,以及vector、set和map等容器的操作。特别强调了迭代器的使用,以及set和map中插入元素和查找定位的方法。
最低0.47元/天 解锁文章
795

被折叠的 条评论
为什么被折叠?



