1

这是“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 中的错误:

没有操作符 "<<" 匹配这些操作数操作数类型是:std::basic_ostream char, std::char_traits> << std::string

4

1 回答 1

3

你忘了

#include <string>

在您的程序中使用operator<<.

于 2013-10-07T02:48:35.110 回答