且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是"专用头"用C?

更新时间:2022-06-10 08:33:09

在我遇到一个 .R 文件中的实例在的面向对象与ANSI-C ,编程凡 .R 文件用作类的重presentation - (如果我理解正确)的方式通过保持内部重新presentation执行信息隐藏和控制访问一类的功能在一个单独的头文件。

The instance in which I've encountered a .r file is in Object-oriented Programming with ANSI-C, where a .r file is used as a "representation" of a class -- (if I understand correctly) a way to perform information hiding by keeping the internal representation and to control access to functions of a class in a separate header file.

只有类的实现将参照 .R 文件,并在这方面,它可以被看作是一个私有头的类。外部接口的类,普通的 .H 使用头文件。

Only the implementation of the class would refer to the .r file, and in that respect it could be regarded as a "private header" to the class. The interface externally to the class, a regular .h header file was used.

作为一个例子,一类可以由三个文件:

As an illustration, a class may be composed of three files:

Circle.h    /* Header file with external interfaces, such as methods. */

Circle.r    /* Representation file for internal use within the class, such as
               structs that define the internal states. */

Circle.c    /* Implementation of the Circle class. */

然后,按照惯例,利用圆形类可能包括程序的 Circle.h 文件作为接口访问类。 Circle.r 严格使用的圆形类的实现,而不是由其他人,因此,使其成为私有头。

Then, by convention, a program utilizing the Circle class may include the Circle.h file as the interface to access the class. Circle.r is strictly used by the implementation of the Circle class and not by others, hence, making it a "private header".

研究文件扩展名是基本上是使用习惯,而不是东西是官方或使用的所有的时间。它是用于方便和普通的头文件来区分与 ^ h 文件扩展名。

The r file extension is basically a convention that is used, and is not something that is "official" or used all the time. It is used for convenience and to differentiate from regular header files with a h file extension.