I'd like to sort a vector of a custom class using std::sort() and overloading the < operator. Following the answer here: Sorting a vector of custom objects, I tried the following code:
class Evnt {
    private:
        int Day, Month;
        string mydata;
    public:
      friend ifstream& operator >>(ifstream &in,Evnt &E){                                                                                                                                                                                    
        char junk;                                                                                                                                                                                                                     
        in >>junk>>E.Month>>junk>>E.Day;                                                                                                                                                                                     
         getline(in,E.mydata);                                                                                                                                                                                                             
        return in;                                                                                                                                                                                                                         
    }            
     bool operator<(const Evnt &E) const{
           if(Month < E.Month)
                   return true;
           else if(Day < E.Day)
                   return true;
           return false;
     }
};
int main(){
     ifstream inpt("inputfile.txt")
     Vector <Evnt> v;
     Evnt tmpevnt;
     while(intp>>tmpevnt)
         v.push_back(tmpevent)
      sort(v.begin(), v.end());
      return 0;
}
The last line somewhat erratically causes segmentation faults. I followed the various examples fairly closely, and so am having issues figuring out what the problem is. It seems to only occur if I read a large number (~20+) items in.
 
    