C++小知识点
The stroke
这个作者很懒,什么都没留下…
展开
-
C++简单的运算符重载
可以简单的把运算符看成一个函数,以此来实现运算符的重载废话不多说直接上代码:#include<stdio.h> #include<iostream> using namespace std; struct ac{ int a; double b; }x1,x2; ac operator+(ac a,ac b){ ac c; c.a=a.a+b.a; c.b=a.b...原创 2018-03-21 19:57:11 · 131 阅读 · 0 评论 -
C++函数重载
函数重载的条件:1、函数名相同2、传入的参数形式或者类型或者顺序不同匹配原则:1、严格匹配#include<stdio.h> #include<iostream> using namespace std; void q(int a){ cout<<a<<endl; cout<<"void q(int a)\n"; } void q(...原创 2018-03-19 21:59:34 · 195 阅读 · 0 评论 -
c++ pair
定义 typedef pair<int,string>p;定义的p相当于struct举个栗子:#include<iostream> #include<cstdio> using namespace std; typedef pair<int,string>p; struct ac{ int first; string second; ...原创 2018-04-01 10:23:55 · 292 阅读 · 0 评论 -
数据结构 C++STL
什么是数据结构:数据集合规则操作栈 stack:规则:last in first out 后入先出 LIFO操作:stack<> name;push(x) :在栈顶添加元素xpop() :从栈顶弹出元素empty() :检查栈是否为空size() :返回大小top() :返回元素个数队列 queue:规则 :先入先出 FIFO操作: queue<> name;back() ...转载 2018-04-01 21:09:46 · 126 阅读 · 0 评论