- 论坛徽章:
- 0
|
//我认为这个是正确的,但是编译不过去,请指教一下。谢谢!!!!!
#include<iostream>;
using namespace std;
class date
{
int month,day,year;
public:
date(int mo=0,int dy=0,int yr=0);
friend ostream& operator << (ostream& ostr,const date& x);
};
date::date(int mo,int dy,int yr)
{
month=mo;
day=dy;
year=yr;
}
ostream& operator << (ostream& ostr,const date& x)
{
ostr<<x.month<<'/'<<x.day<<'/'<<x.year;
return ostr;
}
///////////////////////////////////////////////////////////
int main()
{
date m(4,5,1997);
cout<<m<<endl; //想按 4/5/1997 的格式输出
return 0;
} |
|