virual Listing sort(string field);
要求:
This is a new method. This method returns a copy of the
invoking Listing object sorted by the field name given in the parameter. Use an
appropriate STL sorting function to sort the advertisements. To sort based on
the field name given by the parameter field, consider using an
STL sort function that uses a predicate to determine object equality. The field
names that can be passed into this function are "email,"
"start," "close," and "quantity."
其中listing中的其他定义我也给出来
#ifndef LISTING_H
#define LISTING_H
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <functional>
#include "Advertisement.h"
using namespace std;
class Listing;
class Listing {
protected:
typedef vector<Advertisement*> Container;
public:
typedef Container::iterator iterator;
protected:
Container objects;
public:
virtual ~Listing() {};
virtual Advertisement* operator[](const int& number);
virtual void add(Advertisement* ptr);
virtual iterator begin();
virtual iterator end();
// return a sorted copy of this Listing
virtual Listing sort(string field);
// return a filtered by keyword copy of this Listing
virtual Listing filter(string keyword);
};
#endif
湖上湖
慕田峪7331174
相关分类