球大神帮忙,关于容器的有关问题

球大神帮忙,关于容器的问题
#include<iostream>
#include<vector>
#include<fstream>
#include<algorithm>
#include<iomanip>
using namespace std;
class Movie{
public :
Movie(){}


/*friend ostream & operator <<(ostream & os ,const Movie & movie){
return os<<movie.m_name<<" "<<movie.m_company<<" " <<movie.m_gross;
}
friend istream & operator >> (ostream & is ,Movie & movie ){
return is >> movie.m_name>>movie.m_company>>movie.m_gross;
}*/
friend istream& operator>> (istream& is, Movie& movie) {
  return is >> movie.m_name >> movie.m_company >> movie.m_gross;
  }
  friend ostream& operator<< (ostream& os, const Movie& movie) {
  return os << setiosflags (ios::left) << setw (48) << movie.m_name << setw (20) << movie.m_company << movie.m_gross;
  }
//bool operator< (const Movie& movie) const {
  // return getgross () > movie.getgross ();}
bool operator< (const Movie& movie) const {//就是这两句。。。
  return getgross () > movie.getgross ();
  }
private :
double getgross(){
string gross =m_gross;
string::size_type pos=0;
while((pos=gross.find_first_of("$,",pos)!=string::npos))
gross.erase(pos,1);

return atof(gross.c_str());
}
string m_name;
string m_gross;
string m_company;
};

bool ReadMovie(const char * filename,vector<Movie> movie){
ifstream ifs(filename);
if(!ifs)
{
perror("ifstream: open");
return -1;
}
while(1){
Movie movies ;
if(!(ifs>>movies))
if(!ifs.eof())
{
perror("ifstream: Read");
ifs.close();
return -1;
}
else 
break;
movie.push_back(movies);
}
ifs.close();
return true;
}
int main(int argc ,char* argv[]){
if(argc <3)
 cout << "用法:" << argv[0] << " <原始文件> <榜单文件>" << endl;
  return -1;
  
vector <Movie> movie;
if(!(ReadMovie(argv[1],movie)))
{
return -1;
}
//出错信息:

//for(vector <Movie> :: iterator it = movie.begin();it != movie.end();it++)
// cout<<* it <<endl;
return 0;
}
movie.cpp: In member function ‘bool Movie::operator<(const Movie&) const’:
movie.cpp:27: error: passing ‘const Movie’ as ‘this’ argument of ‘double Movie::getgross()’ discards qualifiers
movie.cpp:27: error: passing ‘const Movie’ as ‘this’ argument of ‘double Movie::getgross()’ discards qualifiers




------解决方案--------------------
请不要在const成员函数中调用非const成员函数。将const函数operator<的const修饰去掉即可。
operator<为const成员函数,所传递的this指针类型为const Movie * const *this;
而在operator<函数中调用了非const函数getgross,c++规定const对象调用const成员函数,所以operator<
会调用const函数getgross,而你却没有定义const函数getgross,所以会出问题。