什么是"专用头"用C? [英] What is a "private header" in C?

查看:119
本文介绍了什么是"专用头"用C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习 C 近日,在我的教科书之一,我发现了.R扩展名的参考文件。现在,你可以想像,谷歌搜索R或文件扩展名R是不是生产性的,所以我不知道你能不能帮我。

I've been learning C recently, and in one of my textbooks I found a reference to a file with the ".r" extension. Now, as you can imagine, googling "r" or "file extension r" is not productive, so I wonder if you could help me out.

它出现在以下code座

It appears in the following code block

#include "new.r"

static const struct Class _String = {
  sizeof(struct String),
  String_ctor, String_dtor,
  String_clone, String_differ
};

const void * String = & _String;

笔者提到,它是一个私有头,但我希望他能一直为究竟是什么更清晰。

The author mentions that it is a "private header", but I wish he could have been more clear as to what exactly that is.

推荐答案

在我遇到一个 .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.

这篇关于什么是"专用头"用C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆