// definition of the class student. Each student has a name and average. // // notice the ifdef below. This makes sure that this class is only // defined once, even if a file includes this file more than once // (anything that includes both compsci.h and bio.h would do this!) #ifndef _STUDENT_H #define _STUDENT_H #include #include class student { private: char *name; double average; public: // default constructor intializes everything to nothing... student() { name=NULL; average=0.0; } // constructor that accepts a name and average student( char *s, double x) { name = new char[ strlen(s)+1]; strcpy(name,s); average=x; } // destructor must free up memory used for the name ~student() { delete[] name; } // prints itself out void print() { cout << "Name: " << name << endl; cout << "Average: " << average << endl; } }; #endif _STUDENT_H