STL学习笔记二:模版中的几个问题
2012-02-21 22:32
113 查看
1.模版函数
#include <iostream>
using namespace std;
template<class T>
void print(T prt)
{
cout<<prt<<endl;
}
int main()
{
char a = 'A';
print(a);
return 0;
}
2.使用前一个模版参数限定后一个模版参数,试说出下面程序的结果。
#include <iostream>
using namespace std;
template<class T>
class queue{
public:
queue(){ cout<<"queue"<<endl; }
};
template<class T,class sequeue = queue<T>>
class stack
{
public:
stack(){ cout<<"stack"<<endl; }
private:
sequeue e;
};
int main()
{
stack<int> x;
return 0;
}
#include <iostream>
using namespace std;
template<class T>
void print(T prt)
{
cout<<prt<<endl;
}
int main()
{
char a = 'A';
print(a);
return 0;
}
2.使用前一个模版参数限定后一个模版参数,试说出下面程序的结果。
#include <iostream>
using namespace std;
template<class T>
class queue{
public:
queue(){ cout<<"queue"<<endl; }
};
template<class T,class sequeue = queue<T>>
class stack
{
public:
stack(){ cout<<"stack"<<endl; }
private:
sequeue e;
};
int main()
{
stack<int> x;
return 0;
}
相关文章推荐
- EXT学习笔记——几个小问题
- STL学习笔记之 (一)模版
- 【扫盲贴】Petshop三层架构学习笔记:几个基础问题Q&A
- STL学习笔记一:模版类属的特殊化处理.
- C++ Standard Stl -- SGI STL源码学习笔记(05) stl_vector 与 一些问题的细化 1
- 算法导论学习笔记-5.4 概率分析和指示器随机变量的应用-几个有趣的问题
- JavaWeb技术学习笔记(2)-关于tomcat的几个问题
- C++ Standard Stl -- SGI STL源码学习笔记(06) stl_vector 与 一些问题的细化 2 push_back函数剖析
- java学习笔记---Java可变参数方法重载时要注意的几个问题
- [学习笔记]学C#遇到的几个问题
- 【C++学习笔记】关于预处理器的几个问题
- STL学习笔记:用非递归的方法实现汉诺塔问题
- NHibernate学习笔记(1) —— 使用NHibernate中应注意的几个小问题
- C++ Standard Stl -- SGI STL源码学习笔记(07) stl_vector 与 一些问题的细化 3 resize函数剖析
- 工作学习笔记——近期的几个技术问题
- 【C++学习笔记】不知道算哪方面的问题~暂且认定为对STL的理解错误
- sqlserver -- 学习笔记(八)体验charindex、stuff 和 for xml path在实际问题中的应用及几个问题的探讨
- Oracle 学习过程中的笔记以及几个问题
- STL学习笔记--排序算法
- 【stl学习笔记】set、multiset