![](/img/trans.png)
[英]Compilation error - more than one instance of constructor "std::basic_string<_Elem, _Traits, _Alloc>::basic_string
[英]Compiling error that says 'std::basic_string<charT, _Traits, _Alloc>
问题是要遍历一个段落,直到遇到一个空行。
这是给我标题中提到的错误的代码
#include <iostream>
#include <string>
#include <vector>
int main()
{
using namespace std;
string word;
vector<string>text;
while(cin>>word)
{
text.push_back(word);
}
for(auto it = text.begin(); it != text.end() && !(*it).empty; it++)
{
cout<<*it<<endl;
}
}
是什么导致错误,解决方法是什么?
我是一个初学者,刚刚开始使用迭代器。
empty
是一个功能。
#include <iostream>
#include <string>
#include <vector>
int main()
{
using namespace std;
string word;
vector<string>text;
while(cin>>word)
{
text.push_back(word);
}
for(auto it = text.begin(); it != text.end() && !(*it).empty(); it++)
{
cout<<*it<<endl;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.