/***2-2***/
/*编写一个函数NewDate,为2-1题中的结构类型变量动态分配空间,此函数返回一个指针,指向结构变量的起始位置*/
#include "iostream.h"
template
struct Time
{
Time(const T& Year=0,const T& Month=0,const T& Day=0 )
{
year=Year,month=Month,day=Day;
}
friend Time* NewDate(T year,T month,T day)
{
return new Time(year,month,day);
}
T year;
T month;
T day;
};
int main()
{
Time temp;
Time *birthday=NewDate(1980,10,16);
cout<year<<","<month<<","<day<return 0;
}
阅读(1245) | 评论(2) | 转发(0) |