|
还请教一下,下面错在哪?
#include <iostream>
#include <string>
using namespace std;
class Month
{
public:
Month(){};
Month(string month,int day,int year);
string getMonth()const;
int getDay()const;
int getYear()const;
private:
string TheMonth;
int TheDay,
TheYear;
};
Month::Month(string month,int day,int year)
{
string TheMonth=month;
int TheDay=day,
TheYear=year;
}
inline string Month::getMonth()const
{
if (TheMonth=="March")
return 1;
else if(TheMonth=="April")
return 2;
else if(TheMonth=="May")
return 3;
else if(TheMonth=="June")
return 4;
else if(TheMonth=="July")
return 5;
else if(TheMonth=="August")
return 6;
else if(TheMonth=="September")
return 7;
else if(TheMonth=="October")
return 8;
else if(TheMonth=="November")
return 9;
else if(TheMonth=="DeceMber")
return 10;
else if(TheMonth=="January")
return 11;
else if(TheMonth=="February")
return 12;
}
错误信息:error C2664: '__thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(co
nst class std::allocator<char> &)' : cannot convert parameter 1 from 'const int' to 'const class std::allocator<char> &'
Reason: cannot convert from 'const int' to 'const class std::allocator<char>'
No constructor could take the source type, or constructor overload resolution was ambiguous |
|