C++中如何在类模板外定义函数
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/17 19:53:18
C++中如何在类模板外定义函数
#include
using namespace std;
template
class Compare
{ private:
numtype x;
numtype y;
public:
Compare(numtype a,numtype b)
{
x=a;
y=b;
}
numtype max()
{
return (x>y)?x:y;
}
numtype min()
{
return (x
#include
using namespace std;
template
class Compare
{ private:
numtype x;
numtype y;
public:
Compare(numtype a,numtype b)
{
x=a;
y=b;
}
numtype max()
{
return (x>y)?x:y;
}
numtype min()
{
return (x
#include
using namespace std;
template
class Compare
{
private:
numtype x;
numtype y;
public:
Compare(numtype,numtype);
numtype max();
numtype min();
};
// 在类模板外面定义其成员函数:
template
Compare::Compare(numtype a,numtype b){
x = a;
y = b;
}
template
numtype Compare::max(){
return (x>y)? x:y;
}
template
numtype Compare::min(){
return (x
using namespace std;
template
class Compare
{
private:
numtype x;
numtype y;
public:
Compare(numtype,numtype);
numtype max();
numtype min();
};
// 在类模板外面定义其成员函数:
template
Compare::Compare(numtype a,numtype b){
x = a;
y = b;
}
template
numtype Compare::max(){
return (x>y)? x:y;
}
template
numtype Compare::min(){
return (x