In the .cpp file, it doesn't know what itemType is, it says it hasn't been defined, but I clearly defined it in the header file. Where have I gone wrong?
Is it necessary to again declare a private: and public: instead the .cpp file, or is the compiler able to know which is which based on the header file?
Thank you both, that clears things up.
One last question: if I didn't have a header file but wanted another class to be able to utilize the functions of this class, could they simply #include the .cpp file?
And to clear things up for anyone who may have the same question:
1. You don't redefine the class in the .cpp file, you simply use the scope resolution operator (::) to specify that it's located in the header file, since the header file is where you defined the class.
2. You don't need to specify public/private inside the .cpp file when already specified in the header.
The files should look like:
1 2 3 4 5 6 7 8
class Item //item.h
{
private:
public:
Item();
string itemType;
};