#include <iostream>
#include <vector>
#include <string>
#include<algorithm>
using namespace std;

class person {
protected:
	string name;
	
public:
	
	int ID;
	person(string name, int ID) :name(name), ID(ID) {};
	
	int showID() {
		cout<<name<<", "<<"ID="<<ID<<", ";
		return 0;
		};
	virtual int showS() = 0;
};

class student :public person {
private:
	int score;
public:
	
	student(string name, int ID, int score) :person(name, ID), score(score) {};
	int showS() {
		cout <<"成績:"<<score;
		return 0;
	};
};


class teacher :public person {
private:
	int salary;
public:
	
	teacher(string name, int ID, int salary) :person(name, ID), salary(salary) {};
	int showS() {
		cout << "薪水:" << salary;
		return 0;
	};
};
struct cmp
{
	inline bool operator() (const person& a, const person& b)
	{
		return (a.ID < b.ID);
	}
};


void main()
{
	person* p;
	student s2("Candy", 333, 90);
	student s1("John", 111, 80);
	teacher t("Mary", 222, 1000);
	
	vector<person*> aa;
	p = &s2;
	aa.push_back(p);
	p = &s1;
	aa.push_back(p);
	p = &t;
	aa.push_back(p);
	
	sort(aa.begin(), aa.end(), cmp());
	vector< person*>::iterator it;
	
	for (it = aa.begin();
		it != aa.end(); ++it) {
		
		(*it)->showID();
		(*it)->showS();
		cout << endl;
	}
	
	system("pause");
}