<STL> pair随笔
2010-12-18 16:46
267 查看
C++标准中提供了pair<T1,T2>类型,今天想自己写一个,在实际动手过程中,自定义的类名不能是pair,否则会和C++标准中的pair类冲突,于是我定义成了pair1。这里我有点不太明白的是,我们都知道pair是在头文件utility.h中定义的,我并没有引入这个头文件,但居然编译的时候提示pair已经定义,不明白....
#include <iostream> #include <string> using namespace std; template<class T1,class T2> class pair1 { public: T1 first; T2 second; //pair1():first(T1()),second(T2()){} pair1():first(),second(){} pair1(const T1& t1,const T2& t2):first(t1),second(t2){} }; int main() { pair1<int,int>p1; pair1<string,int>p2("hicjiajia",425); cout<<p1.first<<" "<<p1.second<<endl; cout<<p2.first<<" "<<p2.second<<endl; system("pause"); return 0; }
相关文章推荐
- <STL> pair随笔
- C# KeyValuePair<TKey,TValue>的用法【转】
- Mybatis简单入门<学习随笔>
- C++ std::pair<>
- 随笔-<c:out> <c:set>标签使用
- std::pair<MAP::iterator,bool>用法,可用来判断插入式否成功
- 我的Android进阶之旅------>android如何将List<NameValuePair>请求参数列表转换为json格式
- Instability(typedef pair<LL,int> P;)
- 上一篇随笔<深入剖析ASP.NET组件设计>一书中第三章关于ASP.NET运行原理的补白
- DWR框架快速入门<学习随笔>
- List<KeyValuePair<int, DateTime> 用法
- <随笔>我的计算机视觉之路(一):转行CV
- KeyValuePair<byte, string> 类型的数据如何绑定到ComboBox控件上
- UESTC 1603 BanG Dreamer 小根堆、贪心+set<pair<int, int>>+low_bound
- <续>jmeter随笔(12)--定制json响应结果断言
- 看<Asp.net夜话>随笔(2013-10-13)
- Android Post参数提交 List<NameValuePair>,web端获取数据
- c++中pair<>的成员无法初始化make_pair为NULL
- ReferenceQueue<T>随笔
- set<pair<int,int> >的用法