-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvoter.cpp
More file actions
executable file
·34 lines (24 loc) · 961 Bytes
/
voter.cpp
File metadata and controls
executable file
·34 lines (24 loc) · 961 Bytes
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
#include <iostream>
#include <stdio.h>
#include "voter.h"
using namespace std;
voter::voter(char* Id, char* Name, char* Surname, short Age, bool Sex, int Postal_code): id(Id), name(Name), surname(Surname), age(Age), sex(Sex), postal_code(Postal_code)
{ /* cout << "A new voter has been created!\n"; */ }
voter::~voter(void)
{ delete[] id; delete[] name; delete[] surname; /* cout << "A voter has been destructed!\n"; */ }
/* returns -1 if this->id < v->id,
returns 1 if this->id > v->id and
returns 0 if they are equal */
short voter::compare(voter* v)
{
return strcmp(id, v->id);
}
short voter::compare(char* str)
{
return -strcmp(id, str);
}
void voter::print(FILE* output)
{
// cout << id << " " << name << " " << surname << " " << age << " " << (sex ? 'M' : 'F') << " " << postal_code << endl;
fprintf(output, "%s %s %s %d %c %d\n", id, name, surname, age, (sex ? 'M' : 'F'), postal_code);
}