So im doing a program where i need to take dates from a text file and insert it into an array and do the following:
Create a minimal DateType class which provides at least these operations:
1) SetDate to assign a value to an existing DateType object (parameters of month, day,
2) An input function that would read dates directly in the format used by the input file.
3) Output to display a date in the format mm/dd/yyyy.
4) Compare two dates for == and > (separate functions).
I got most of it done but i need to make it look for two of the same date and delete one of them if it finds two of the same date. I went to a tutor and he told me that i have to first overload the == and > < operators then then do a bubble sort to order them from least to greatest or vise versa and then create a loop to see if the next one in the array is the same ex: array[i] == array[i+1] ( which is the easy part)
what i need help on is the overloading operators and the bubble sort. I have the idea but i don't know where to start. Any help would be appreciated.
Here's whats i have so far.
using namespace std;
struct calender // struct to prepare for the array
calender arr; // put the struct into the array
void readDate() // reads in the info from the text file and puts it into the array
for( int i=0; !dates.eof() && i < 18;i++)
dates >> arr[i].month;
dates >> arr[i].day;
dates >> arr[i].year;
void compareDate( )
readDate(); // this is where i was thinking of making the bubble sort but i heard the main is where it needs to be.
void printDate( ) // gets the info from readDate and prints out the dates in format
for( int i=0; i < 18;i++)
cout << arr[i].month << "/" << arr[i].day << "/" << arr[i].year << endl;
any help would be appreciated. I'm not looking for someone to do the work for me (it would be nice though) but if someone could give me a push to the right direction, that would help a lot. Thanks in advance