| 论坛注册| 加入收藏 | 设为首页| RSS
Google
您当前的位置:首页 > Linux频道 > Linux开发区 > 软件开发

C++自动化(模板元)编程基础与应用

时间:2006-06-16 11:29:29  来源:中国IT实验室  作者:Linux联盟收集
emplate />::yes
<:string><:complex<:complex<:endl;
<:endl;
<:endl;
<:endl;
<:endl;
<:endl;
<:string><:endl;
<:complex<:endl;
<:complex<:endl;
<:complex<:string><:complex<:complex<:string><:complex<:complex<< std::endl; std::cout << "Derived5 is kind of AnotherTemplate? "
<:string><:complex<:complex<:endl;
<:endl;
<:endl;
<:endl;
<:endl;
<:endl;
<:string><:endl;
<:complex<:endl;
<:complex<:endl;
<:complex<:string><:complex<:complex<:string><:complex<:complex<< is_kind_of::yes << std::endl;vDTLinux联盟
std::cout << "Derived6 is kind of AnotherTemplate? "
<:string><:complex<:complex<:endl;
<:endl;
<:endl;
<:endl;
<:endl;
<:endl;
<:string><:endl;
<:complex<:endl;
<:complex<:endl;
<:complex<:string><:complex<:complex<:string><:complex<:complex<< is_kind_of::yes << std::endl;vDTLinux联盟
std::cout << "Derived7 is kind of AnotherTemplate? "
<:string><:complex<:complex<:endl;
<:endl;
<:endl;
<:endl;
<:endl;
<:endl;
<:string><:endl;
<:complex<:endl;
<:complex<:endl;
<:complex<:string><:complex<:complex<:string><:complex<:complex<< is_kind_of::yes << std::endl;vDTLinux联盟
std::cout << "Derived8 is kind of AnotherTemplate? "
<:string><:complex<:complex<:endl;
<:endl;
<:endl;
<:endl;
<:endl;
<:endl;
<:string><:endl;
<:complex<:endl;
<:complex<:endl;
<:complex<:string><:complex<:complex<:string><:complex<:complex<< is_kind_of::yes << std::endl;vDTLinux联盟
std::cout << "Derived9 is kind of AnotherTemplate? "
<:string><:complex<:complex<:endl;
<:endl;
<:endl;
<:endl;
<:endl;
<:endl;
<:string><:endl;
<:complex<:endl;
<:complex<:endl;
<:complex<:string><:complex<:complex<:string><:complex<:complex<< is_kind_of::yes << std::endl;vDTLinux联盟
return 0;vDTLinux联盟
}vDTLinux联盟
#endif//CODE3vDTLinux联盟
///////////////////////////////////////////////////////////////vDTLinux联盟
//该程序的运行结果如下:vDTLinux联盟
/*************************************************************vDTLinux联盟
Derived1 is kind of Template? 1vDTLinux联盟
Derived2 is kind of Template? 1vDTLinux联盟
Derived3 is kind of Template? 1vDTLinux联盟
Derived4 is kind of Template? 1vDTLinux联盟
Derived5 is kind of Template? 1vDTLinux联盟
Derived6 is kind of Template? 1vDTLinux联盟
Derived7 is kind of Template? 1vDTLinux联盟
Derived8 is kind of Template? 1vDTLinux联盟
Derived9 is kind of Template? 1vDTLinux联盟
Derived1 is kind of AnotherTemplate? 0vDTLinux联盟
Derived2 is kind of AnotherTemplate? 0vDTLinux联盟
Derived3 is kind of AnotherTemplate? 0vDTLinux联盟
Derived4 is kind of AnotherTemplate? 0vDTLinux联盟
Derived5 is kind of AnotherTemplate? 0vDTLinux联盟
Derived6 is kind of AnotherTemplate? 0vDTLinux联盟
Derived7 is kind of AnotherTemplate? 0vDTLinux联盟
Derived8 is kind of AnotherTemplate? 0vDTLinux联盟
Derived9 is kind of AnotherTemplate? 0vDTLinux联盟
****************************************************************/vDTLinux联盟
////////////////////////////////////////////////////////////////vDTLinux联盟
#if 0vDTLinux联盟
vDTLinux联盟
从CODE3的运行结果可以看出:我们已经成功的实现了判断某个型别是否是某个模板类vDTLinux联盟
的派生类或者是直接实例化的类的能力。因此我们就可以在自己编写代码的时候利用这些vDTLinux联盟
功能来实现静态分派的能力。vDTLinux联盟
vDTLinux联盟
至于第三种方法已经在前面的章节中讨论过了。根据索引号访问scatter产生的代码的vDTLinux联盟
同类型变量的方法就是采用了第三种方法。vDTLinux联盟
vDTLinux联盟
到目前为止,已经讨论了我所知道的C++里面的类型识别的一般方法。具体如何应用就要vDTLinux联盟
看您的发挥了。我编写的撤销和重做库中就采用了这里的方法来识别简单类型和复合类型的。vDTLinux联盟
vDTLinux联盟
#endif
 11/11   |‹ ‹‹ 9 10 11

来顶一下
近回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
相关文章
    无相关信息
栏目更新
栏目热门