Created
January 5, 2012 12:56
-
-
Save mauricio/1565152 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "studentinfo.h" | |
bool compare( const StudentInfo& x, const StudentInfo& y ) | |
{ | |
return x.name() < y.name(); | |
} | |
StudentInfo::StudentInfo() : midterm(0), final(0) {} | |
StudentInfo::StudentInfo( double _midterm, double _final, std::vector<double> _homework ) { | |
this->final = _final; | |
this->midterm = _midterm; | |
this->homework = _homework; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef STUDENTINFO_H | |
#define STUDENTINFO_H | |
#include <istream> | |
#include <string> | |
#include <vector> | |
class StudentInfo | |
{ | |
public: | |
StudentInfo(); | |
StudentInfo( double _midterm, double _final, std::vector<double>& _homework ); | |
double grade() const; | |
std::istream& read(std::istream&); | |
std::string name() const { return _name; } | |
private: | |
std::string _name; | |
double midterm, final; | |
std::vector<double> homework; | |
}; | |
bool compare( const StudentInfo& x, const StudentInfo& y ); | |
#endif // STUDENTINFO_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can replace this constructor:
by this (write this in the header file):