vector< string>之间的区别X;和vector< string> x(常量字符串& s){} [英] Difference between vector<string> x; and vector<string> x(const string& 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 $>的一个参数的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< string>之间的区别X;和vector< string> x(常量字符串& s){}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!