gpt4 book ai didi

c++ - 为什么我得到 "non-aggregate cannot be initialized with initializer list"

转载 作者:IT老高 更新时间:2023-10-28 12:35:52 25 4
gpt4 key购买 nike

std::map<std::string, int> m = {
{"Marc G.", 123},
{"Zulija N.", 456},
{"John D.", 369}
};

在 Xcode 中,我将 C++ 语言方言设置为“C++0x [-std=c++0x]”,并将 C++ 标准库设置为“支持 C++0X 的 libc++ LLVM C++ 标准库”

我需要设置其他东西吗?

最佳答案

EDIT 10/2013:这个答案真的很老了,Apple Clang 现在确实支持这个。

自 Clang 3.0 起尚不支持 C++11 初始化列表

在此处查看实现状态:Clang C++11 implementation status

(如果只有编译器支持此功能,您的语法看起来是正确的)

关于c++ - 为什么我得到 "non-aggregate cannot be initialized with initializer list",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8920699/

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