-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDriver.h
59 lines (50 loc) · 1.45 KB
/
Driver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/****************************************************************************
Ryan Bridges
February 29, 2014
File Name: Driver.h
Description: Defines the UCSDStudent class
****************************************************************************/
#ifndef DRIVER_H
#define DRIVER_H
#include <string.h>
#include <iostream>
using namespace std;
class UCSDStudent
{
friend ostream &operator <<(ostream &, const UCSDStudent &);
char name[20];
long studentnum;
public:
/**
* UCSDStudent constructor initializes variables for a new UCSDStudent
*/
UCSDStudent (char *nm, long val = 0) : studentnum (val)
{
strcpy (name, nm);
}
/**
* operator const char * overloads the const char * operator by returning
* the name field
*/
operator const char *(void) const
{
return name;
}
/**
* operator == overloads the == operator so it works on UCSDStudents
* @param vvv a reference to the student to compare to
*/
long operator == (const UCSDStudent &vvv) const
{
return ! strcmp (name, vvv.name);
}
/**
* operator > overloads the > operator to work on UCSDStudents
* vvv the student to compare to
*/
long operator > (const UCSDStudent &vvv) const
{
return (strcmp (name, vvv.name) > 0) ? 1 : 0;
}
};
#endif