日期问题建立具有如下功能的类Date:
#include<iostream>#include"string.h"
using namespace std;
class Date
{
public:
Date(int ,int,int);
Date (char*s,int d,int y)
{strcpy(str,s);
day=d;
year=y;}
void display1();
void display2();
private:
char str[5];
int month;
int day;
int year;
};
Date::Date(int m,int d,int y):month(m),day(d),year(y)
{}
void Date::display1()
{cout<<month<<"/"<<day<<"/"<<year<<endl;
cout<<month<<" "<<day<<" "<<year<<endl;}
void Date::display2()
{cout<<str<<" "<<day<<","<<year<<endl;}
int main()
{Date d(2,14,1992);
d.display1();
d.display2("June",14,1992);
return 0;
}
运行时报错:function does not take 3 parameters,求指教