是否可以创建自己的新头文件?谁能帮助我如何用c ++创建我自己的头文件?
答案 0 :(得分:27)
是的,当然可以,但在此之前,您需要了解哪些头文件以及如何正确使用它们。
file:yourname.h
#ifndef YOUR_NAME_INCLUDE
#define YOUR_NAME_INCLUDE
/* Your function statement here */
#endif
yourname.cpp
#include <iostream.h>
#include "yourname.h"
/* Your function definition here */
的main.cpp
#include <iostream.h>
#include "yourname.h"
/* Your function calling here */
要了解有关头文件和包含语句的更多信息,请单击下面的链接。
答案 1 :(得分:4)
是的,您可以创建自己的头文件。
file:myheader.h
#ifndef MYHEADER
#define MYHEADER
......
#endif
file:myclass.cpp
#include <iostream.h>
#include "myheader.h"