使用模板实现编译期间多态
2012-04-19 21:59
357 查看
#include <iostream> using namespace std; class DemoOne{ public: void f(bool someParm=true){ cout<<"DemoOne f functions\n";} void g(){ cout<<"DemoOne g functions\n";} // other functions... }; class DemoTwo{ public: void f(){ cout<<"DemoTwo f functions\n";} void g(double a=1.12,double b=1.123){ cout<<"DemoTwo g functions\n";} // other functions... }; template<typename T> void h(T& t){ t.f(); t.g(); } int _tmain(int argc, _TCHAR* argv[]) { DemoOne one; DemoTwo two; h(one); h(two); return 0; }
相关文章推荐
- 使用模板实现编译期间多态(类名当参数)
- C++模板元编程之使用模板,对数组进行“编译期间求和”
- c++重载操作符的使用及实现编译多态
- 使用模板来实现多态
- 【转载】Discuz! 中实现不同版块使用不同的模板文件 亲测在X2.5适用
- 编译和使用apue.3e源码并实现第一个ls.c程序
- Servlet的概述 什么是Servlet:Servlet的入门servlet的实现关系;使用Eclipse的模板创建servlet
- Intellij IDEA 使用jrebel运行spring-boot并实现自动编译进行热部署
- 使用模板实现ASP代码与页面分离
- 探索之闭包 七 使用闭包来实现模板方法模式
- asp.net实现在非MVC中使用Razor模板引擎的方法
- 使用 Velocity 实现客户端和服务器端模板
- iOS编译FFmpeg及使用实现视频播放
- express3.x_02之使用视图模板(能实现列表的遍历,不用写for循环)
- 使用模板实现ASP代码与页面分离
- Cocos2d-x使用Luajit将Lua脚本编译为bytecode,从而实现加密
- Eclipse环境下 使用Gradle进行编译实现自动分包
- 关于使用js实现按期间查询的简单demo
- 使用模板实现ASP代码与页面分离
- 使用kernel编译+busybox定制Linux系统--实现ssh远程登录+web服务的迷你主机