Reputation:
I would like to use unmanaged C++.
The following code:
#include"string.h"
std::string nodename[100];
Gives me the following compilation error:
'std' : is not a class or namespace name
Upvotes: 3
Views: 874
Reputation: 400194
You're using the wrong header file. You should be #include
ing <string>
, not "string.h"
:
<string>
is the header file that defines the C++ STL class std::string
<string.h>
is the header file for the C standard library of string functions, which operate on C strings (char *
)<cstring>
is the header file like <string.h>
, but it declares all of the C string functions inside of the std
namespaceFor system header files like these, you should always #include
them with angle brackets, not with double quotes.
Upvotes: 15
Reputation: 503805
Try something like:
#include <string>
int main(void)
{
std::string nodeName[100];
}
It's just string
, not string.h
.
Upvotes: 9