template関数とtemplateクラス
875 ワード
#include
using namespace std;
template
class Poly{
private:
Type base;
Type height;
public:
Poly(Type b = 0, Type h = 0):base(b),height(h){}
Type getArea()const{
return base * height;
}
template inline int compare(const T &t1, const T &t2){
if(t1 < t2) return -1;
if(t1 > t2) return 1;
return 0;
}
};
int main(){
int b1 = 2, h1 = 3;
Poly p1(b1, h1);
cout< "<
p2(b2, h2);
cout< "<