0
#include <bits/stdc++.h>
int main() {
std::string foo = "string_1";
std::string bar = "string_2";
std::vector<std::string> myvector;
myvector.push_back (foo);
myvector.push_back (std::move(bar));
for (std::string x:myvector)
std::cout << x << '\n' ;
}
是如何形成的代码是不同势当我交流什么是“&”类名之后是什么意思?
for (std::string x:myvector)
呢?
for (std::string& x:myvector)
我猜有很多的时候我能找到的地方,但我不知道这是什么措施的名字,所以我不知道我应该寻找。如果对你来说更容易,链接到解释就足够了。
编辑:
什么是差异性之探源:
for(auto x:my_vector)
for(auto& x:my_vector)
for(auto&& x:my_vector)
这就是所谓的“参考”。 –
的可能的复制[C++拷贝构造的语法:是符号参考R/L值?](https://stackoverflow.com/questions/33290801/c-copy-constructor-syntax-is-ampersand-reference-to-rl - 值) –
不包括<比特/ STDC++。H>,它是一个非标准报头,并不意味着列入。 – 2017-07-18 19:14:56