Skip to content

头文件的声明规范

1. 防卫式命名规范

C
#ifndef _COMPLEX_
#define _COMPLEX_

// 头文件内容

#include <cmath>

// 前置声明
class ostream;
class complex;

// 类声明

complex&
    _doapl (complex* ths, const complex& r);

// 类定义
complex::function...

#endif

只有第一次引入,没有定义过变量的时候才会声明一次。

Released under the MIT License.