Hello, I'm taking a C++ class, and I keep running into a strange occurrence. I'm writing a simulation program with people sending emails to one another and one of the requirements is we use abstract base classes when dealing with email forwarding strategies. The two ABC's in my project are EvaluateMessage and EvaluateRecipient. The Person class holds a pointer to each and when a Person is created a child class is chosen (based on an input file) to instantiate the pointers to. EvaluateMessage compiles and works just fine, however EvaluateRecipient is giving me problems and I don't know why. EvaluateRecipient works in other classes without a problem and the code all compiles and the input is all read fine, but when I include it in Person.h its gives me an error list this long in Visual Studio:
(The actual error list is much much longer but it's repetitive). I'm using guards in my header files, but reading the errors it seems that by add EvaluateRecipient to Person, I'm stripping all references of Person out of the project somehow. I don't know what's going on.
Errors:
EvaluateRecipient.hCode:1>evaluaterecipient.h(18): error C2065: 'Person' : undeclared identifier 1>evaluaterecipient.h(18): error C2059: syntax error : '>' 1>evaluaterecipient.h(18): error C2065: 'Person' : undeclared identifier 1>evaluaterecipient.h(18): error C2065: 'person' : undeclared identifier 1>evaluaterecipient.h(18): error C2143: syntax error : missing ',' before ')' 1>evaluaterecipient.h(19): error C2143: syntax error : missing ';' before '}' 1>evaluaterecipient.h(23): error C2143: syntax error : missing ';' before '{' 1>evaluaterecipient.h(28): error C2065: 'Person' : undeclared identifier 1>evaluaterecipient.h(28): error C2059: syntax error : '>' 1>evaluaterecipient.h(28): error C2065: 'Person' : undeclared identifier 1>evaluaterecipient.h(28): error C2065: 'person' : undeclared identifier 1>evaluaterecipient.h(28): error C2143: syntax error : missing ',' before ')' 1>evaluaterecipient.h(29): error C2143: syntax error : missing ';' before '}' 1>evaluaterecipient.h(33): error C2143: syntax error : missing ';' before '{' 1>evaluaterecipient.h(38): error C2065: 'Person' : undeclared identifier 1>evaluaterecipient.h(38): error C2059: syntax error : '>' 1>evaluaterecipient.h(38): error C2065: 'Person' : undeclared identifier 1>evaluaterecipient.h(38): error C2065: 'person' : undeclared identifier 1>evaluaterecipient.h(38): error C2143: syntax error : missing ',' before ')' 1> EvaluateRecipient.cpp 1>person.h(36): error C2143: syntax error : missing ';' before '*' 1>person.h(36): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>person.h(36): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Person.hCode:#ifndef EVALUATE_RECIPIENT_H #define EVALUATE_RECIPIENT_H #include <list> #include "Person.h" #include "Message.h" using namespace std; class EvaluateRecipient { public: // Constructor EvaluateRecipient(); virtual list<Person*> getList(Message* message, Person* person) = 0; }; // Forward the message to all members of the contact list class RStrategy1: public EvaluateRecipient { public: // Constructor RStrategy1(); virtual list<Person*> getList(Message* message, Person* person); }; // Forward the message to all members of the contact list except (possibly) the sender class RStrategy2: public EvaluateRecipient { public: // Constructor RStrategy2(); virtual list<Person*> getList(Message* message, Person* person); }; // Forward the message to the "next" member on the person's contact list class RStrategy3: public EvaluateRecipient { public: // Constructor RStrategy3(); virtual list<Person*> getList(Message* message, Person* person); }; #endif // EVALUATE RECIPIENT_H
Any help would be much appreciated, thanks!Code:#ifndef PERSON_H #define PERSON_H #include <map> #include <list> #include <string> #include "EvaluateMessage.h" #include "EvaluateRecipient.h" using namespace std; class Person { public: // Constructor Person(string emailAddress); // Email of the person string email; // A list of strings (email addresses), or the Person object's contact list list<string> contactList; // A list of Message objects, the inbox of the Person object list<Message*> inbox; // A map that maps a MessageContent to an unsigned int map<MessageContent*, unsigned int> timesSeen; // Pointer to strategies // Forwarding strategy EvaluateMessage* mStrategy; EvaluateRecipient* rStrategy; }; #endif // PERSON_H


Reply With Quote

Bookmarks