大神快来帮忙看看,求解
#include "stdafx.h"#include <vector>
#include <iostream.h>
bool isshorter(const string &s1, const string &s2)
{
return s1.size() < s2.size();
}
bool GT6( const string &s)
{
return s.size() >= 6;
}
string make_plural(size_t ctr, string &words, string &word)
{
return (ctr == 1)? words : words+word;
}
int _tmain(int argc, _TCHAR* argv[])
{
vector<string> words;
string next_word;
while (std::cin >> next_word)
{
words.push_back(next_word);
}
sort(words.begin(),words.end());
vector<string>::iterator end_unique = unique(words.begin(),words.end());
words.erase(end_unique,words.end());
stable_sort(words.begin(),words.end(),isshorter);
vector<string>::size_type wc = count_if(words.begin(),words.end(),GT6);
std::cout << wc <<"" <<make_plural(wc,"word","s") <<"6 characters or longer" <<endl;
return 0;
}
我在vs2008上编译时一直出现如下错误
1>d:\lianxic++\readwords\readwords\readwords.cpp(6) : fatal error C1083: 无法打开包括文件:“iostream.h”: No such file or directory
修改为#include <iostream>
using namespace std;
后出现一堆如下错误1>d:\lianxic++\readwords\readwords\readwords.cpp(18) : error C2784: “std::_Vb_iterator<_Sizet,_Difft,_MycontTy> std::operator +(_Difft,std::_Vb_iterator<_Sizet,_Difft,_MycontTy>)”: 无法从“std::string”为“std::_Vb_iterator<_Sizet,_Difft,_MycontTy>”推导 模板 参数
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\vector(1854) : 参见“std::operator +”的声明
1>d:\lianxic++\readwords\readwords\readwords.cpp(18) : error C2784: “std::_Vb_iterator<_Sizet,_Difft,_MycontTy> std::operator +(_Difft,std::_Vb_iterator<_Sizet,_Difft,_MycontTy>)”: 无法从“std::string”为“std::_Vb_iterator<_Sizet,_Difft,_MycontTy>”推导 模板 参数
不知道该怎么修改。希望大声快来帮帮