模板特化和强制转换的问题
来源:互联网 发布:如何查看linux密码 编辑:程序博客网 时间:2024/05/19 16:50
/******************************************************************** file name : CLK.h author : Clark/陈泽丹 created : 2011-11-10 purpose : 模板特化和强制转换问题*********************************************************************/#include <iostream>using namespace std;class Base{public:Base(){ m_BaseDate = 5; }protected:int m_BaseDate;};struct kkk{int k;kkk(){k = 102;}};template <class T> class Trigger: public Base{public:Trigger(T data){cout<<"非法类型"<<endl;}};template <>class Trigger<int>: public Base{public:Trigger(int data){cout<<data<<endl;}};template <>class Trigger<kkk>: public Base{public:Trigger(kkk data){cout<<data.k<<endl;}};class Q:public Trigger<int>{};template<class T>void Recv(T& date){Trigger<T> triger(date);}void Recv1(char* buf){int *pSTrig = (int *) buf;if (NULL == pSTrig){return;}cout<<*pSTrig<<endl;}void main(){//传入整型int iType = 5;Recv(iType);kkk kd;Recv(kd);//传入非法类型double dType = 5;Recv(dType);//传入整型Recv1((char*)&iType);//传入非法类型Recv1((char*)&dType);system("pause");}/*5非法类型50请按任意键继续. . .*/
- 模板特化和强制转换的问题
- 类模板的特化和偏特化
- c++模板的特化和偏特化
- 模板的特化和偏特化
- 模板的特化和偏特化
- 模板的特化(特化和偏特化)
- 模板的特化和萃取
- 模板特化和偏特化
- 模板特化和偏特化
- 模板特化和偏特化
- 模板特化和偏特化
- 模板特化和偏特化 .
- 模板特化和偏特化
- 模板特化和偏特化
- 模板特化和偏特化
- 模板特化和偏特化
- 模板和模板特化
- 模板和模板特化
- Android中Activity之间传递自定义对象
- getAbsolutePath getCanonicalPath 区别以及 当前目录、上级目录 用法
- C#中的除法和四舍五入运算
- linuxLog服务器
- 详解SQL Server Profiler分析死锁几大步骤
- 模板特化和强制转换的问题
- 关于数据库操作整理的一些经验
- Hibernate自定义数据类型UserType
- 关于Windows中的hook(钩子)【转自网络】
- hdu 2102 A计划
- 连接模式:提高数据库性能的捷径
- Spring中Transactional配置
- PHP学习笔记(1)--基础知识篇
- 自定义拦截器实现权限管理