My header file goes like this:
std::string bookNo; //compiles without error
This is a function of your specific compiler/implementation of the standard library. Generally speaking, to make your code 100% portable, you should include the
string header, because not every compiler will do this. I know that current versions of both
clang allow it (I'm uncertain about MSVC), but in order to make your code standards-compliant, you should always include the
string header where you want to use
std::string. If you ever find yourself having to develop for a platform where the compiler doesn't do this, the code you've given above will fail to compile and you'll have to spend time and effort debugging it. So why bother? Toss in that
#include <string>, keep programming, and save yourself the trouble of fixing it later.