zoukankan      html  css  js  c++  java
  • 使用模板实现编译期间多态

    #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;
    }

    image

  • 相关阅读:
    一般处理程序页ashx 序列化 Json数组
    SQL server 分页
    MySQL 分页
    获取网站的BaseURL
    java学习书籍推荐
    查询并关闭指定端口进程
    ettercap使用
    MS10-046漏洞利用
    MS12-020漏洞利用
    入侵安卓手机
  • 原文地址:https://www.cnblogs.com/rollenholt/p/2458017.html
Copyright © 2011-2022 走看看