求助,友元 重载操作符
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
class GT_cls{
public:
GT_cls(int val):bound(val){
}
bool operator()(const std::string& s){
return s.size()>=bound;
}
friend std::istream& operator>>(std::istream& in, std::vector<std::string>& str){
std::string s;
for(std::string::size_type ix=0;ix<10;ix++){
getline(in,s);
str.push_back(s);
}
return in;
}
private:
std::string::size_type bound;
};
int main(){
std::vector<std::string> words;
std::cin>>words;
std::cout<<count_if(words.begin(),words.end(),GT_cls(6))<<std::endl;
}