gpt4 book ai didi

c++ - "<<"运算符不适用于 visual studio 2012 中的字符串数组

转载 作者:行者123 更新时间:2023-11-30 02:52:10 28 4
gpt4 key购买 nike

<分区>

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

no operator "<<" matches these operands operand types are: std::basic_ostream char, std::char_traits> << std::string

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com