60 - class Templates

2018-01-08  本文已影响0人  社交帐号直接注册
#include <iostream>
using namespace std;

template<class t>
class bucky
{
    t first,second;
public:
    bucky(t a,t b)
    {
        first=a;
        second=b;
    }
    t bigger();
};

template<class t>
t bucky<t>::bigger()
{
    return (first>second?first:second);
}
int main()
{
    bucky<int>bo(69,105);
    cout << bo.bigger();
}
上一篇 下一篇

猜你喜欢

热点阅读