这是“Date.h”类
class Date
{
private:
int day;
int month;
int year;
public:
void PrintDateV2();
Date(int, int, int);
~Date();
};
这是“Date.cpp”,其中包含无法正常工作的指定函数的实现
void Date::PrintDateV2()
{
string months[12]={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
/*line of error*/cout << months[month-1] << endl;//<< ":: " << day << ", " << year << endl;
}
这是错误列表中visual studio中的错误:
无操作员“&lt;&lt;”匹配这些操作数的操作数类型是:std :: basic_ostream char,std :: char_traits&gt; &LT;&LT; std :: string
答案 0 :(得分:3)
你忘记了
#include <string>
在使用operator<<
之前,在您的计划中。