A Vector of Rational Numbers

  1. Use the CRational class you defined in the previous exercise. Create a vector of CRational.
  2. Combine your class with the following main program:
    
    int main()
    {
        string s;
        vector<CRational> mydata;
    
        while (cin >> s)
        {
            CRational c(s);
            mydata.push_back(c);
        }
    
        std::sort(mydata.begin(), mydata.end(), less);
        for (int i=0; i<mydata.size(); i++)
        {
            mydata.at(i).Print();
        }
        return 0;
    }
    
    
  3. You need to define a function bool less(CRational, CRational) to help sort() comparing rational numbers.

For the input

1/2
1/3
1/4
1/5
2/3
2/5

The output should be

1/5
1/4
1/3
2/5
1/2
2/3