代码如下:
#include <iostream> #include <map> #include <string> #include <ctime> #define MAX 10 using namespace std; class Employee{ public: string m_Name; Employee(string name, int salary) { this->m_Name = name; this->m_Salary = salary; } void setSalary(int salary) { this->m_Salary = salary; } int getSalary() { return this->m_Salary; } private: int m_Salary; }; class MyCompare{ public: bool operator()(const Employee &p1, const Employee &p2) const { return p1.getSalary() > p2.getSalary(); } }; void printEmployee(const multimap<int, Employee, MyCompare> &mp) { } int main(void) { cout << rand() / RAND_MAX << endl; return 0; }
运行出错: