如何获得vector向量中元素的地址
答案:2 悬赏:40 手机版
解决时间 2021-02-04 21:34
- 提问者网友:十年饮冰
- 2021-02-04 06:58
如何获得vector向量中元素的地址
最佳答案
- 五星知识达人网友:西岸风
- 2021-02-04 07:19
#include
#include
#include
using namespace std;
int main()
{
cout << "Vector for string" << endl;
const string str[] = { "The", "vector", "for", "strings." };
vector < string > svec(str, str + 4);
vector < string >::iterator its; // iterator for the string vector
for (its = svec.begin(); its != svec.end(); its++)
cout << *its << " "; // dereference the iterator to get the string
cout << "\n";
return 0;
}
#include
#include
using namespace std;
int main()
{
cout << "Vector for string" << endl;
const string str[] = { "The", "vector", "for", "strings." };
vector < string > svec(str, str + 4);
vector < string >::iterator its; // iterator for the string vector
for (its = svec.begin(); its != svec.end(); its++)
cout << *its << " "; // dereference the iterator to get the string
cout << "\n";
return 0;
}
全部回答
- 1楼网友:撞了怀
- 2021-02-04 07:37
你先把向量的定义贴出来吧
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯