#include "stdafx.h"
#include <string>
#include <list>
#include <algorithm>
#include <iostream>
using namespace std;
class Student
{
public:
Student(){}
Student(string name,string sex,int age,string number);
int getAge(){return _age;}
string getNumber(){return _number;}
bool operator==(const string&str)//重载操作符
{
return str==_number;
}
bool operator==(const int&stemp)
{
return stemp==_age;
}
private:
string _name;
string _sex;
int _age;
string _number;
};
Student::Student(string name,string sex,int age,string number)
{
_name=name;
_sex=sex;
_age=age;
_number=number;
}
int _tmain(int argc, _TCHAR* argv[])
{
Student st[5]={
Student("la","男",12,"122"),
Student("小林","男",13,"123"),
Student("小林","男",14,"124")
};
string strnum;
cout<<"enter number:";
cin>>strnum;
Student *present=find(st,st+4,strnum);
cout<<"这个学生的学号是:"<<present->getNumber()<<endl;
int age;
cout<<"enter age: ";
cin>>age;
Student *pre=find(st,st+4,age);
cout<<"这个学生的年龄是:"<<pre->getAge();
getchar();
getchar();
return 0;
}