Visual C++ 声明一个字符串数组 [英] visual C++ declaring a string array
本文介绍了Visual C++ 声明一个字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用非托管 C++.
I would like to use unmanaged C++.
以下代码:
#include"string.h"
std::string nodename[100];
给我以下编译错误:
'std' : 不是类或命名空间姓名
'std' : is not a class or namespace name
推荐答案
您使用了错误的头文件.你应该 #include
ing
,而不是 "string.h"
:
You're using the wrong header file. You should be #include
ing <string>
, not "string.h"
:
是定义 C++ STL 类std::string
的头文件
是C标准字符串函数库的头文件,对C字符串进行操作(char *
)
是类似于
的头文件,但它声明了std<中的所有 C 字符串函数/code> 命名空间
<string>
is the header file that defines the C++ STL classstd::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 thestd
namespace
对于这样的系统头文件,你应该总是#include
用尖括号而不是双引号将它们#include
.
For system header files like these, you should always #include
them with angle brackets, not with double quotes.
这篇关于Visual C++ 声明一个字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文