date.h file:
#include <iostream>
using namespace std;
(3) class Date {
private:
string date;
string start_time;
string stop_time;
public:
Date();
Date(Date&);
Date(string, string, string);
//overloaded constructor;
void set_date(string);
void set_start_time(string);
//void check_validity(string, string, string);
void set_stop_time(string);
string get_date();
string get_start_time();
string get_stop_time();
void input();
void print();
~Date();
};
date.cpp file:
#include <iostream>
#include "date.h"
using namespace std;
Date::Date()
{
//default constructor
date = '\0';
start_time = '\0';
stop_time = '\0';
}
Date::Date(Date& d)
{
//copy constructor
date = d.date;
start_time = d.start_time;
stop_time = d.stop_time;
}
Date::Date(string date, string start_time, string stop_time)
{
this->date = date;
this->start_time = start_time;
this->stop_time = stop_time;
}
void Date::set_date(string date)
{
this->date = date;
}
void Date::set_start_time(string start_time)
{
this->start_time = start_time;
}
void Date::set_stop_time(string stop_time)
{
this->stop_time = stop_time;
}
string Date:: get_date()
{
return this->date;
}
string Date::get_start_time()
{
return this->start_time;
}
string Date::get_stop_time()
{
return this->stop_time;
}
void Date::input()
{
cout << "enter the date of the wedding event=";
cin >> date;
cout << endl;
cout << "Enter the starting time of the wedding cermony=" << endl;
cin >> start_time;
cout << endl;
cout << "Enter the ending time of the wedding cermony=" << endl;
cin >> stop_time;
cout << endl;
}
void Date::print()
{
cout << "The Date of the wedding event is=" << this->date << endl;
cout << "The Starting time of the weeding event is" << this->start_time << endl;
cout << "The End time of the weeding event is" << this->stop_time << endl;
}
Date::~Date()
{
//destructor
date = '\0';
start_time = '\0';
stop_time = '\0';
}
main.cpp
#include <iostream>
#include <cstdlib>
#include "date.h"
#include "event.h"
#include "meeting.h"
#include "contact.h"
#include "appointment.h"
#include "calender.h"
using namespace std;
int main()
{
Date d;
d.set_date("15-12-2002");
d.set_start_time("03:00 PM");
d.set_stop_time("07:00 PM");
Calender C;
Event* A = new Appointment("0342-1447420", d,"wedding cermony");
cout<<A->toString();
Event* B = new Meeting("0342-1447421", d,"Disussion");
cout<<B->toString();
Calender c;
c.addevent(A);
c.addevent(B);
int count = 0;
Event** e = c.findEventsByKeyword("Disussion",count);
cout<<e[0]->get_title();
system("pause");
return 0;
}
I am getting this error:
redefinition of class Date in date.h file at line number 3.
I try my best to solve it but I failed. What is wrong in it? It is in C++. Here I am attaching picture of error: