#include<string>#include<List>#include<iostream>using namespace std;int main() { string s = "Mark"; List<string> l {"name of the guy"," is Mark"}; cout<<s<<endl; int size = sizeof(l)/sizeof(l[0]); for (int i=0;i<size;i++) { cout<<l[i]<<endl; } return 0; }
I / O是
strtest.cpp:8:47: error: in C++98 ‘l’ must be initialized by constructor,not by ‘{...}’ List<string> l {"name of the guy"," is Mark"};解决方法 如果使用gcc,则使用c 98而不是c 11的编译器
g++ -std=c++11 -o strtest strtest.cpp
你可以用gnu 11代替c 11
总结以上是内存溢出为你收集整理的在c 11中初始化字符串列表全部内容,希望文章能够帮你解决在c 11中初始化字符串列表所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)