在LearnCpp.com | 1.10 — 初步了解预处理器。在Header guards下,有这些代码片段:
添加.h:
#include "mymath.h"
int add(int x, int y);
减去.h:
#include "mymath.h"
int subtract(int x, int y);
主.cpp:
#include "add.h"
#include "subtract.h"
在实现header guard时,提到如下:
#ifndef ADD_H
#define ADD_H
// your declarations here
#endif
- 什么可以在这里声明?而且,应该
int main()
追#endif
吗? - 添加
_H
约定还是必须做的事情?
谢谢。