Error with classes and multiple files

I've spent the last day fixing the errors in my program and I'm stuck on these. This program messes around with dates, it can get the current date, user can change the date, add dates, compare dates etc.

The errors I'm getting is:
In file included from date.cpp:1:0,
from date_driver.cpp:7:
date.h:4:7: error: redefinition of ‘class Date’
In file included from date_driver.cpp:6:0:
date.h:4:7: error: previous definition of ‘class Date’
date_driver.cpp: In function ‘int main()’:
date_driver.cpp:15:11: error: statement cannot resolve address of overloaded function
date_driver.cpp:16:12: error: statement cannot resolve address of overloaded function

This is my date_driver.cpp basically the main.cpp. There's not much to it, I haven't gotten around to testing it yet since I can't fix the errors.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
#include <math.h>
#include "date.h"
#include "date.cpp"
using namespace std;

int main()
{
        Date d1;
        d1.setDate(1900, 12, 23);
        d1.getMonth;
        d1.getDay;
        d1.getYear;
}


These are the class files: http://codepad.org/nDmrZhj2 and
http://codepad.org/C5kjvdl6

Due to the character max length I can't paste the code in here.
Last edited on
You get the redefinition error because you include both date.cpp and date.h
Topic archived. No new replies allowed.