0%

类模板与函数模板

类模板与函数模板

https://blog.csdn.net/EmSoftEn/article/details/50421124

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
template <class T> // declare a template, type T, no semicolon
class Compare {
public:
Compare(T a, T b)
{
x = a;
y = b;
}
T max()
{
return (x>y) ? x : y;
}
T min()
{
return (x<y) ? x : y;
}
T test();
private:
T x;
T y;
};

template <class T>
T Compare<T>::test()
{
T a;
return a;
}
跑步练琴写代码