template (2)
#include <stdio.h>
template <class T, class M>
class Base {
public:
T x;
T y;
M a;
M b;
public:
T max()
{
return (x>y) ? (x):(y);
}
M min()
{
return (a<b) ? (a):(b);
}
};
void test()
{
//Base<int, int> b;
//Base<char, char> b;
Base<int, char> b;
b.x = 1;
b.y = 2;
b.a = 10;
b.b = 20;
int max = 0;
max = b.max();
int min = 0;
min = b.min();
printf("max: %d, min: %d\n", max, min);
}
int main(int argc, char **argv)
{
test();
}

浙公网安备 33010602011771号