vector< string>之间的区别X;和vector< string> x(常量字符串& s){} [英] Difference between vector<string> x; and vector<string> x(const string& s) {}

查看:138
本文介绍了vector< string>之间的区别X;和vector< string> x(常量字符串& s){}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过Andrew Koenig和Barbara Moo学习 Accelerated C ++ 中的向量。任何人都可以解释这些差异吗?

  vector< string> X; 

 矢量<串GT; x(const string& s){...} 

第二个定义了一个函数

这本书的确切代码像这样开始:

  map< string,vector< int> > xref(istream& in,vector< string> find_words(const string&)= split){


解决方案

  vector< string> X; 

这是一个名为 x 类型 vector< string>

  vector< string> x(const string& s){...} 

这是一个名为<$ c $ 常量字符串& 并返回一个向量< string> 的一个参数的c> x c>



正如你所看到的,它们是不同的野兽。


I'm learning about vectors in Accelerated C++ by Andrew Koenig and Barbara Moo. Can anyone explain the difference between these?

vector<string> x;

and

vector<string> x(const string& s) { ... }

Does the second one define a function x whose return type must be a vector and whose return value is stored somehow in x?

The exact code from the book starts like this:

map<string, vector<int> > xref(istream& in, vector<string> find_words(const string&) = split) {

解决方案

vector<string> x;

This is a declaration of a variable named x of type vector<string>

vector<string> x(const string& s) { ... }

this is a function named x that takes 1 parameter of type const string& and returns a vector<string>

As you can see they are different beasts.

这篇关于vector&lt; string&gt;之间的区别X;和vector&lt; string&gt; x(常量字符串&amp; s){}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆