In my header file I'm getting the
error: ‘string’ has not been declared
error but at the top of the file I have #include <string>
, so how can I be getting this error?
In my header file I'm getting the
error: ‘string’ has not been declared
error but at the top of the file I have #include <string>
, so how can I be getting this error?
string
resides in the std
namespace, you have to use std::string
or introduce it into the scope via using directives or using declarations.
Like Georg said, string resides in the std
namespace and is referred to as std::string
. If you don't want to go around and change all your code, you can:
#define string std::string
Or (and don't quote me on this) there should be a directive like namespace std
to declare that it uses the std
namespace by default.