#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;
}
我得到的原始错误代码:
pruebastr.cpp:10:8: error: expected expression str = {"Hi","Example", "Error"}; ^ 1 error generated.
我是不是以错误的方式定义了数组,还是错误地初始化了它?
最佳答案
确保您的编译器标准标志 (std) 至少设置为 c++11
关于c++ - 是否可以创建一个字符串数组,如果可以,为什么我会收到此错误 : error: expected expression?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41352582/