#include <iostream>
#include <string>
using std::string;
using std::cout;
using std::cin;
using std::endl;
template< class T, class M>
class Math
{
public:
M plus( T a, M b )
{
return ( a + b );
};
private:
T max;
T min;
};
class Student
{
public:
Student();
Student( string num, float Eng );
~Student();
Student operator +( Student &student );
void Information();
void setAddress( Student *N );
Student * getAddress();
private:
string number;
float English;
Student *next;
};
Student::Student()
{
}
Student::Student( string num, float Eng )
{
number = num;
English = Eng;
}
Student::~Student()
{
}
Student Student::operator +( Student &student )
{
Student container;
container.number = number + student.number;
container.English = English + student.English;
return container;
}
void Student::Information()
{
cout<< "学号:"<< number<< "成绩:"<< English<< endl;
cout<< "地址:"<< next<< endl;
}
void Student::setAddress( Student *N )
{
next = N;
}
Student *Student::getAddress()
{
cout<< "本对象地址:"<< next<< endl;
return next;
}
void main()
{
/*
Student student1( "100323", 100.0 );
Student student2( "100000", 90.0 );
Student student3( "0", 0.0 );
student1.Information();
student2.Information();
student3.Information();
*/
Student *student1 = new Student( "100323", 140.0 );
Student *student2 = new Student( "100000", 145 );
Student *student3 = new Student( "0", 0 );
//student2->setAddress( student1 );
student1->getAddress();
student2->getAddress();
student3->getAddress();
*student3 = *student1 + *student2;
student3->Information();
Math< int, char > math1;
cout<< math1.plus( 12, 'A' )<< endl;
}