首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >c++ string数组初始化

c++ string数组初始化
EN

Stack Overflow用户
提问于 2012-03-09 07:29:42
回答 4查看 161.9K关注 0票数 27

我知道我可以在C++中做到这一点:

string s[] = {"hi", "there"};

但是,有没有办法以这种方式去关心一个数组而不去关心string s[]呢?

例如:

void foo(string[] strArray){
  // some code
}

string s[] = {"hi", "there"}; // Works
foo(s); // Works

foo(new string[]{"hi", "there"}); // Doesn't work
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9626722

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档