Hello. Whenever I declare a string in a class it compiles an error stating 'string does not name a type' please help
#ifndef LIBRARY
#define LIBRARY
class book {
private:
string author;
string title;
int publicationYear;
public:
string returnAuthor(){return author;}
string returnTitle(){return title;}
int returnPublicationYear(){return publicationYear;}
};
class library {
};
#endif
You need to both #include the proper header file for the std::string class and properly scope that standard class.
What is the proper header file?
Did you even try to research this simple topic? "C++ string"
Hello TheDomesticUser2,
Just because your error appears to be in the class which looks like a header file does not mean that is where the error started.
You are missing the code that has "main" in it.
This is a case where all the code is needed.
Andy