爱问知识人 爱问共享资料 医院库

VC6.0中的重载问题

首页

VC6.0中的重载问题


        

提交回答
好评回答
  • 2018-04-07 06:23:45
      把重载的函数体放在类中实现就可以了,代码如下:#include<iostream>#include<iomanip> using namespace std;//-------------------------------------------- class Date{ public:int year,month,day; void init(); public: Date(const string& s); Date(int y=2000,int m=1,int d=1); bool isLeapYear()const; friend ostream& operator<<(ostream& o,const Date& d){ o<<setfill('0')<<setw(4)<< ar<<"-"<<setw(2)<< nth<<"-"; return o<<setw(2)<<d。
      day<<"-"<<setfill(' '); }};//-------------------------------------------- void Date::init() { if(year>5000 || year<1 || month<1 || month>12 || day<1 || day>31) exit(1);//停机 }//----------------------------------------------- Date::Date(const string& s) { year=atoi( bstr(0,4)。
      c_str()); month=atoi( bstr(5,2)。c_str()); day=atoi( bstr(8,2)。
      c_str()); init(); }//----------------------------------------------- Date::Date(int y,int m,int d) { year=y; month=m; day=d; init(); }//----------------------------------------------- bool Date::isLeapYear()const { return (year%4==0 && year%100)||year%400==0; }//----------------------------------------------- //----------------------------------------------- int main() { Date c(string("2005-12-28")); Date d(2003,12,6); Date e(2002); Date f(2002,12); Date g;cout<<c<<d<<e<<f<<g; return 0; }。

    t***

    2018-04-07 06:23:45

类似问题

换一换

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈
关注
爱问

关注爱问微信公众号,开启知识之旅,随时随地了解最新资讯。

确定举报此问题

举报原因(必选):