源码

C和C中的头部守卫


LearnCpp.com | 1.10 — A first look at the preprocessor.在Header guards下,有一些代码片段:

add.h:

#include "mymath.h"
int add(int x, int y);

subtract.h:

#include "mymath.h"
int subtract(int x, int y);

main.cpp中:

#include "add.h"
#include "subtract.h"

在实施头部防护时,提到如下:

#ifndef ADD_H
#define ADD_H

// your declarations here

#endif

>宣言可以在这里发表什么?并且,int main()应该在#endif之后吗?
>将_H添加为约定或必须执行的操作?

谢谢.

(0)

本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/checzhongdetoubushouwei.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 20, 2019 at 04:49 上午

热评文章