I have this date.h
, where I have a class Date
. I define my methods and then implement them in a date.cpp
but the compiler throws me errors of:
error: "method ...." previously defined here. and error: redefinition of "method ....".
I get an error and I do not know why. I do not know what I'm doing wrong. Help.
codes:
date.h:
#ifndef DATE_H_INCLUDED
#define DATE_H_INCLUDED
using namespace std;
class Date {
private:
int year;
int day;
int month;
string fullDate;
public:
int getYear();
int getDay();
int getMonth();
string getFullDate();
void setYear(const int&);
void setDay(const int&);
void setMonth(const int&);
void _fullDate();
};
and date.cpp:
#include <iostream>
#include <string>
#include <sstream>
#include "date.h"
using namespace std;
int Date::getYear(){
return year;
}
int Date::getDay(){
return day;
}
int Date::getMonth(){
return month;
}
string Date::getFullDate(){
return fullDate;
}
void Date::setYear(const int& x){
year = x;
}
void Date::setDay(const int& x){
day = x;
}
void Date::setMonth(const int& x) {
month = x;
}
void Date::_fullDate(){
stringstream full;
full << day << "/" << month << "/" << year;
fullDate = full.str();
}
#endif // DATE_H_INCLUDED