Visual C++ 声明一个字符串数组 [英] visual C++ declaring a string array

查看:26
本文介绍了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

推荐答案

您使用了错误的头文件.你应该 #includeing ,而不是 "string.h":

You're using the wrong header file. You should be #includeing <string>, not "string.h":

  • 是定义 C++ STL 类 std::string
  • 的头文件
  • 是C标准字符串函数库的头文件,对C字符串进行操作(char *)
  • 是类似于 的头文件,但它声明了 std<中的所有 C 字符串函数/code> 命名空间
  • <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 namespace

对于这样的系统头文件,你应该总是#include用尖括号而不是双引号将它们#include.

For system header files like these, you should always #include them with angle brackets, not with double quotes.

这篇关于Visual C++ 声明一个字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆