Getting incomplete type in Dentist Appointment Program
I am creating a Dental Appointment project and I am getting an error that says. field 'myPerson' has an incomplete type. How can I fix this?
Here is DentalAppointment.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#ifndef DENTALAPPOINTMENT_H
#define DENTALAPPOINTMENT_H
#include "Person.h"
#include "Date.h"
#include "Time.h"
#include<string>
using namespace std;
class Person;
class DentalAppointment
{
friend class Person;
public:
void appointmentTime(int,Time);
DentalAppointment(string,string,int,int,int,int,int);
void displayApp(Person,Date);
private:
int extra;
Person myPerson;
Date myDate;
Time myTime;
};
|
Here is Person.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#ifndef PERSON_H
#define PERSON_H
#include <string>
#include "DentalAppointment.h"
using namespace std;
class DentalAppointment;
class Person
{
friend class DentalAppointment;
public:
Person();
string getFirstName();
string getLastName();
void setFirstName(string);
void setLastName(string);
void showPerson();
private:
string firstName;
string lastName;
};
#endif // PERSON_H
|
You have a circular dependency here. I don't think you need to include DentalAppointment.h in Person.h.
Also, I'd avoid having using namespace std;
in a header file, for all the usual reasons people give.
Sorry for the late reply. I was at work. That fixed my problem. Thanks!
You're welcome :)
Topic archived. No new replies allowed.