我们如何制作C ++头文件? [英] how we make a c++ header file?

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

问题描述

嗨!
请告诉我如何在C ++中创建头文件或.h文件.
请帮帮我.

Hi!
Please tell me how one can create a header or .h file in C++.
Please help me.

Thanks in advance!

推荐答案

由于头文件是纯文本文件,因此可以使用文本文件编辑器(例如Visual C++ IDE的)创建它,或者例如notepad(我建议您 Notepad ++ ).
但是,为了在头文件中写入有意义的内容,您必须(至少)阅读有关C++编程语言的教程.
:)
Since a header file is plain text file, you may create it with a text file editor (like Visual C++ IDE''s one) or, for instance, the notepad (I suggest you Notepad++).
However, in order to write meaningful content inside the header file you have to read (at least) a tutorial about C++ programming language.
:)


在这里问基本的和无礼的问题之前,您应该考虑购买一本好书.我们很乐意提供帮助,但是这样的问题使我们担心我们能说些什么,并希望您能理解.
You should consider buying a good C++ book before asking basic and inane questions here. We love to help, but a question like that leaves us worried what we can say, and hope you will understand it.


如果您使用的是Visual Studio

右键单击项目->添加新项目->头文件->添加头文件名称-> OK

这是使用MSVC的新头文件


如果您使用的是Turbo C或GCC,请使用记事本

打开记事本,然后将文件内的双引号括起来作为"filename.h"

您可以根据需要将其保存到任何路径.

然后在您的cpp文件中,您可以使用include语句将该文件包含在内


这是一个例子...




#include"headerfileName.h"//包括您创建的头文件

int main(){

//code

返回0;
}

祝你好运..! :)
If you are using Visual Studio

Right Click Project -> Add New Item -> Header File -> Add header file Name -> OK

and here is your new header file using MSVC


If in case you are using turbo C or GCC, use notepad

open notepad and save the file within inverted double quotes as "filename.h"

you can save it to any path as required.

Then in you cpp file, you can include this file as using include statement


Here is an example...




#include "headerfileName.h" //including the header file you created

int main() {

//code

return 0;
}

Best of Luck..! :)


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

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