如何包括头文件 [英] How to include header files

查看:123
本文介绍了如何包括头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何导入标题文件是否重要?我看到双引号以及使用的箭头。

Does it matter how I import header files? I've seen double quotes as well as arrows used.

#include <stdlib.h>
#include "Some_Header.h"

方式?试验这个,似乎没有事情,但我认为必须有一个教程做它的方式他们做的原因。

Does it matter if they're capitalized a certain way as well? Experimenting around with this, it seems neither matters, but I figure there must be a reason for tutorials doing it the way they do.

另一个问题是,(来自Java这里),我如何访问一个类外面定义的文件?说,我有one.cpp和two.cpp。

Another question is, (coming from Java here), how do I access a class outside the file it was defined in? Say, I have one.cpp and two.cpp.

在one.cpp中:

class Something {
    ...

在two.cpp中:

class SomethingElse {
    Something *example;
    ...

这样吗?在Java中,你只要在类名前加上public。在C ++中,争用类似乎有点难度。

Like that? In Java you'd just preface a class name with "public." In C++, wrangling classes seems to be a bit more difficult..

推荐答案

中的尖括号#include 指令表示搜索路径限于system包含目录。双引号意味着搜索路径包括当前目录,后跟系统include目录。

Angle brackets in #include directives means the search path is limited to the "system" include directories. Double quotes mean the search path includes the current directory, followed by the system include directories.

使用区分大小写的文件系统。它听起来像你可能使用Windows或Mac OS X,其中文件名默认情况下不区分大小写。

The case of the filename matters when your OS is using a filesystem that is case sensitive. It sounds like you might be using Windows or Mac OS X, where filenames are case insensitive by default.

这篇关于如何包括头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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