#include<iostream>
#include<string.h>
#include <stdlib.h>
const int TOTAL=4;
class student
{
private:
char *namept;
int height;
public:
student(char *s, int hght):height(hght)
{
namept=new char[strlen(s)];
strcpy(namept, s);
print();
}
~student()
{
delete [] namept;
}
void print()
{
std::cout<<namept<<" "<<height<<std::endl;
}
friend int tallest(student **l, int n)
{
int top=l[0]->height;
int num=0;
for (int i=1; i< n; ++i)
if (l[i]->height>top)
{
top=l[i]->height;
num=i;
}
return num;
}
};
int main(void)
{
class student* list[TOTAL];
list[0]= new student("John", 180);
list[1]= new student("Adam", 188);
list[2]= new student("Judy", 168);
list[3]= new student("Julia", 175);
int n=tallest(list, TOTAL);
std::cout<<"the tallest one is ";
list[n]->print();
system("pause");
return 0;
}