Newbie level programmer...I've taken two C++ college course and I'm now in a data structures class. Using MSVC++ V.6.
I'm using a class that will be called ItemType and will have one member variable of type string:
Code:
#include <fstream>
#include <string>
const int MAX_ITEMS = 50;
enum RelationType {LESS, GREATER, EQUAL};
class ItemType
{
public:
ItemType();
RelationType ComparedTo(ItemType) const;
void Print(std::ostream&) const;
void Initialize(int number);
private:
string name;
};
I've actually copied this code from our textbook where it was originally coded with a member variable of: int value; Then I am using a sorted list class that will make use of an ItemType object to create a list and manipulate the list.
Problem: When I compile the client file, I get an error that says the following:
1. c:\documents and settings\project#2a\itemtype.h(18) : error C2146: syntax error : missing ';' before identifier 'name'
2. c:\documents and settings\project#2a\itemtype.h(18) : error C2501: 'string' : missing storage-class or type specifiers
3. c:\documents and settings\project#2a\itemtype.h(18) : error C2501: 'name' : missing storage-class or type specifiers
I added the statement: using namespace std; to the header file and the errors go away, however, I believe that is not the right solution (for a reason that I am unsure of at this point). I posed this problem to my instructor and he indicated that I need to modify the envorinment variables.
If anyone here can shed light on this problem I sincerely appreciate it.
Thanks.
Sully