【发布时间】:2022-07-28 23:54:24
【问题描述】:
我正在尝试将列表添加到字符串中。
int main() {
std::cout << "Hello, welcome to Jay's Coffee!!\n";
std::string name; std::cout <<"What is your name "; std::cin >> name;
std::cout <<"Hello " << name << ", thank you so much for coming in today";
std::list <std::string> menu = {"Black Coffee" "Espresso" "Latte" "Cappucino"};
std::cout << name <<",what would you like from our menu today? Here is what we are serving.\n" << menu;
}
返回
invalid operands to binary expression ('basic_ostream<char>' and 'std::list<std::string>' (aka 'list<basic_string<char>>'))
【问题讨论】:
-
没有运算符
-
标准容器没有输入或输出操作符。如果你想做
cout << container,你需要自己写
标签: c++