My first post on StackExchange! I have an assignment for my C++ course; to make an Appointment Class that uses a previous assignment of a Date class (month, day, year) and a Time class (Hour, Minute, AM/PM). I think I have most of the primary/syntax errors out of the way.
My problem is that with how I've currently done the #includes and header files, I get a multiple definitions error of the constructors for Date and Time. (And I don't know much about Templates, but I'm required to work with them.)
My files:
Appointment.cpp
#include "time.cpp" #include "date.cpp" #include "appointment.h"
I need to be able to create a Time/Date object, should I use .h or .cpp files?
Appointment.h
#ifndef _APPOINTMENT_H_ #define _APPOINTMENT_H_ #include <iostream> #include "time.h" #include "date.h"
date.cpp
#ifndef _DATE_CPP_ #define _DATE_CPP_ #include "date.h"
date.h
#ifndef _DATE_H_ #define _DATE_H_
time.cpp
#ifndef _TIME_CPP_ #define _TIME_CPP_ #include "time.h"
time.h
#ifndef _TIME_H_ #define _TIME_H_
The following are related to implementation of the above files:
main.cpp
#include "arrayListType.h" #include "appointment.h" void read(arrayListType<Appointment>&); void output(const arrayListType<Appointment>&); int main() { arrayListType<Appointment> appointments; read(appointments); output(appointments); return 0; }
read.cpp
#include "arrayListType.h" #include "appointment.h" #include <fstream> using namespace std; void read(arrayListType<Appointment>& appointments) {...}
output.cpp
#include "arrayListType.h" #include "appointment.h" #include <iostream> #include <iomanip> using namespace std; void output(const arrayListType<Appointment>& appointments) {...}
arrayListType.h (which has all of the implementation in, as templates)
- itemType.h
Not sure if you need to see the last 2. If I need to post more information, I'm glad to. I have a compressed version of all the files too.