类模板——类模板的特化问题
来源:互联网 发布:数据库笔试题 编辑:程序博客网 时间:2024/05/29 17:37
一、类模板——类模板的特化问题
#include <stdio.h>
#include <stdlib.h>#include <iostream>
#include <string>
#include <Windows.h>
using namespace std;
//类模板的特化问题
template <typename T>
class Type{
public :
static string name(){ return typeid(T).name(); }
};
template <>//必须要
class Type<int>
{
public:
static string name(){ return "int"; };
};
template <>//必须要
class Type<double>
{
public:
static string name(){ return "double"; };
};
template <>//必须要
class Type<float>
{
public:
static string name(){ return "float"; };
};
template <>//必须要
class Type<bool>
{
public:
static string name(){ return "bool"; };
};
void main()
{
cout << Type<int>::name() << endl;
cout << Type<double>::name() << endl;
cout << Type<float>::name() << endl;
cout << Type<bool>::name() << endl;
system("pause");
}
0 0
- 类模板——类模板的特化问题
- 类模板的特化
- 类模板的特化
- 类模板的特化和偏特化
- 类模板的 全特化、偏特化
- 类模板的特化,偏特化
- C++类模板的特化
- C++ 类模板的特化
- 类模板的偏特化
- C++类模板的特化
- C++ 类模板特化
- 类模板与特化
- 类模板特化
- 类模板特化
- 特化类模板成员
- 特化类模板成员
- 模板的特化与偏特化 ,C++类模板的三种特化
- 类模板的全特化和偏特化
- linux下查找文件的方法
- Transact-SQL中使用PATINDEX和STUFF替换字串中非数字字符
- 影像质量评价指标汇总
- Integer to Roman ——解题报告
- 单例模式
- 类模板——类模板的特化问题
- Android---36---读取SD卡内容
- C#中的值传递和引用传递详细解析
- Codeforces 383 A. Milking cows(贪心)
- linux下查看cpu,内存,硬盘等硬件信息的方法
- Android关键资源
- Maximum Depth of Binary Tree -- leetcode
- 解决Matlab: Invalid MEX-file
- 生成二维码报错:IOError: encoder zip not available