是否可以创建一个字符串数组,如果是这样,为什么我会收到此错误:错误:预期表达式?

bio*_*osr 1 c++ arrays string typedef

#include <iostream>
#include <array>
#include <string>

using namespace std;
typedef array<string,3> TString;

int main(){
    TString str;
    str = {"Hi","Example", "Error"};
    cout << str[0] <<endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我得到的原始错误代码:

pruebastr.cpp:10:8:错误:期望的表达式str = {"Hi","Example","Error"}; 生成^ 1错误.

我是以错误的方式定义数组还是错误地初始化它?

kwa*_*sei 5

确保编译器标准标志(std)至少设置为c ++ 11