繁体   English   中英

编译错误提示&#39;std :: basic_string <charT, _Traits, _Alloc>

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM