用date类定制一个模板set<date
但出现如下错误;
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
class date
{
int hour, minute, second;
public:
date(int m_hour, int m_minute, int m_second) :hour(m_hour), minute(m_minute), second(m_second) {};/*同上*/
friend ostream& operator <<(ostream& os, const date* a)
{
os << a->hour << "时" << a->minute << "分" << a->second << "秒" << endl;
return os;
}
};
template<class type>
class set
{
type t;
public:
set(type st) :t(st) {};
void dispaly()
{
cout << t << endl;
}
};
class set<date>
{
date*t;
public:
set(date*st) :t(st) {};
void dispaly()
{
cout << "现在的时间是"<<t << endl;
}
};
int main()
{
set<date>d1 = date(17, 3, 36);
d1.dispaly();
return 0;
}