virual Listing sort(string field); 要求:This is a new method. This method returns a copy of theinvoking Listing object sorted by the field name given in the parameter. Use anappropriate STL sorting function to sort the advertisements. To sort based onthe field name given by the parameter field, consider using anSTL sort function that uses a predicate to determine object equality. The fieldnames 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 Listingvirtual Listing sort(string field);// return a filtered by keyword copy of this Listingvirtual Listing filter(string keyword);};#endif
麻煩幫忙看看以下這個c++函數要怎么寫?
慕桂英4014372
2021-12-07 05:07:17