C ++包括带和不带.h [英] C++ includes with and without .h

查看:114
本文介绍了C ++包括带和不带.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

之间的区别使用#include< filename>和#include< filename.h> in c ++


我从来没有注意到它有任何区别,无论我是否包括.h在一个include的结尾,所以我一直忽略的意思,但我只是注意到我的一个特定的程序,我得到错误memcpy没有声明在这个范围如果我包括字符串,但如果我包括string.h则不能。



首先,我想知道这个的具体原因, 。同时,如果有人可以解释括号中的括号和引号中的含义之间的差异,那么非常感谢。

解决方案

< string> 是包含 std :: string 及其朋友的C ++标准库字符串头文件。 < string.h> 是一个与C标准库不同的头文件,它具有操作C字符串(以null结尾的字符串)和其他相关函数的功能。 p>

这两个是完全不同的,不相关的。在C ++中(如在C中),头文件可以具有任何扩展名。 C ++标准库头文件没有扩展名; C标准库头文件有一个 .h 扩展名。 .hpp .hxx 也很常见。


Possible Duplicate:
What is the difference between using #include<filename> and #include<filename.h> in c++

I've never noticed it making any difference whether or not I include the .h at the end of an include, so I've always ignored the meaning, but I've just noticed in a particular program of mine, I get the error "memcpy was not declared in this scope" if I include "string", but not if I include "string.h".

First of all, I was wondering the specific cause of this, but also generally the difference between the two. At the same time, if someone could explain the difference between includes in angular brackets and those in quotation marks, It'd be much appreciated.

解决方案

<string> is the C++ standard library string header file containing std::string and its friends. <string.h> is a different header, from the C standard library, which has functions for manipulating C strings (null-terminated strings) and other related functions.

The two are entirely different and unrelated. In C++ (as in C), a header file can have any extension. The C++ standard library headers have no extension; the C standard library headers have a .h extension. .hpp or .hxx are also common.

这篇关于C ++包括带和不带.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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