'Class' Type Redefinition

Apr 5, 2011 at 11:05am
Hi Guys:

I am receiving the 'Class' Type Redefinition C2011 error on the Patient class but I haven't been able to figure out why the error is showing. Could you please help me with this one? Thanks.

Ass1.cpp
#include <iostream>
#include <iomanip>
#include "PatientAccount.h"
#include "Surgery.h"
#include "Pharmacy.h"
using namespace std;

PatientAccount.cpp
#include <iostream>
#include "PatientAccount.h"
using namespace std;

Pharmacy.cpp
# include <iostream>
# include "Pharmacy.h"

Surgery.cpp
# include <iostream>
# include "Surgery.h"

Surgery.h
#include "PatientAccount.h"

Pharmacy.h
#include "PatientAccount.h"

The only condition for this to work is that I cannot edit Ass1.cpp

Thanks in Advance,
MTA


Apr 5, 2011 at 12:21pm
Check your header guards ( if you have any )
Apr 5, 2011 at 9:09pm
What are the header guards? This is all I have in the preprocessor directives.
Last edited on Apr 5, 2011 at 9:10pm
Apr 5, 2011 at 9:11pm
1
2
3
4
#ifndef MY_HEADER_GUARD
#define MY_HEADER_GUARD
/*Do some fun stuff*/
#endif //MY_HEADER_GUARD 
Last edited on Apr 5, 2011 at 9:12pm
Apr 5, 2011 at 9:14pm
I don't have any header guards. Where should I put them? The only thing that I cannot do is modify the ass1.cpp.
Apr 5, 2011 at 9:28pm
Hi mta, the header guards should be located at the top of each header file (i.e. files with extension .h), with each guard being unique.

The only thing that I cannot do is modify the ass1.cpp.

I would assume that Ass1.h (if it exists) already has header guards so I wouldn't worry about it.

good luck!
Apr 5, 2011 at 9:50pm
Hi dangrr888:

Ass1.cpp doesn't include any header file. But I am still receiving the same problem. Any Ideas of what can be happening?
Apr 5, 2011 at 10:13pm
Put header guards with unique identifiers in all of your headers
Topic archived. No new replies allowed.