请问“私有头文件”是怎么回事?

来源:百度知道 编辑:UC知道 时间:2024/05/10 14:34:15
头文件还有私有,共有之分吗?
请大家给我解释一下,谢谢
我是在看《高质量C++编程指南》一书中看到“私有头文件”的,下面是摘录:

如果某些头文件是私有的,它不会被用户的程序直接引用,则没有必要公开其“声明”。为了加强信息隐藏,这些私有的头文件可以和定义文件存放于同一个目录。

to moxdiamond,这个技术我是知道的。

私有头文件,就是你自个定义的头文件,引用为#include "my.h",公有文件引用为#include <stdio.h>
A module is a logically related collection of data and code grouped together for convenience. A module consists of a public header file and one or more C source files that implement the public interface and any needed private interfaces. If the module contains multiple C source files, then it may also have a private header file for use only by its own source files.
这段英文讲的很清楚了,私有头文件的作用是为了模块化。
在下拙见,《高质量C++编程指南》并不是好的参考,很多地方讲的不清不楚

没有。
防止被重复包可以用以下形式
#ifndef _XXX_
#define _XXX_
...
#endif // _XXX_
或者#pragma once(视编译器)