帮忙找一下错(调用操作符)

haofang666777 2011-10-22 04:48:10
c++primer 450的例题,
照敲之后运行很多错误;
但是,也找不出来
求知道
代码如下
[code=C/C++]
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
class GT_cls
{
pubilc:
GT_cls(int val):bound(val){}
bool operator()(const string &s)
{
return s.size()>=bound;
}
private:
int bound;
};
int main()
{
vector<string> str;
string s;
while(cin>>s)
str.push_back(s);
cin.clear();
for(int i=0;i<10;i++)
cout<<count_if(str.begin(),str.end(),gt_cle())<<" words "<<i<<" characters or longer"<<endl;
return 0;
}code]
...全文
47 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
haofang666777 2011-10-22
  • 打赏
  • 举报
回复
囧 public写错了
其他就简单了
[Quote=引用 6 楼 mougaidong 的回复:]
C/C++ code
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

class GT_cls
{
public:
GT_cls(int val):bound(val){}
bool operator()(const……
[/Quote]
turing-complete 2011-10-22
  • 打赏
  • 举报
回复
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

class GT_cls
{
public:
GT_cls(int val):bound(val){}
bool operator()(const string &s)
{
return s.size() >= bound;
}
private:
int bound;
};
int main()
{
vector<string> str;
string s;
while(cin>>s)
str.push_back(s);
cin.clear();
for(int i=0;i<10;i++)
cout<<count_if(str.begin(),str.end(),GT_cls(3))<<" words "<<i<<" characters or longer"<<endl;
return 0;
}
turing-complete 2011-10-22
  • 打赏
  • 举报
回复
public 都没写对!
王旺旺旺 2011-10-22
  • 打赏
  • 举报
回复
出现了什么错误啊?
haofang666777 2011-10-22
  • 打赏
  • 举报
回复
没明白你的意思[Quote=引用 2 楼 myhaikuotiankong 的回复:]
是不是把指针的指针传给指针了。。。???
[/Quote]
myhaikuotiankong 2011-10-22
  • 打赏
  • 举报
回复
是不是把指针的指针传给指针了。。。???
haofang666777 2011-10-22
  • 打赏
  • 举报
回复
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
class GT_cls
{
pubilc:
GT_cls(int val):bound(val){}
bool operator()(const string &s)
{
return s.size()>=bound;
}
private:
int bound;
};
int main()
{
vector<string> str;
string s;
while(cin>>s)
str.push_back(s);
cin.clear();
for(int i=0;i<10;i++)
cout<<count_if(str.begin(),str.end(),gt_cle())<<" words "<<i<<" characters or longer"<<endl;
return 0;
}

64,646

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧