.inl文件在C ++中的意义 [英] Significance of a .inl file in C++

查看:611
本文介绍了.inl文件在C ++中的意义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.inl文件中声明的优点是什么?何时需要使用相同的?

What are the advantages of having declarations in a .inl file? When would I need to use the same?

推荐答案

.inl 从不是强制性的,对编译器没有特殊意义。

.inl files are never mandatory and have no special significance to the compiler. It's just a way of structuring your code that provides a hint to the humans that might read it.

我使用 .inl 文件的两种情况:

I use .inl files in two cases:


  • 有关内联函数的定义。

  • 模板。

在这两种情况下,我将函数的声明放在头文件中, #include 头文件底部的 .inl 文件。

In both cases, I put the declarations of the functions in a header file, which is included by other files, then I #include the .inl file at the bottom of the header file.

我喜欢它,因为它将接口与实现分离,并使头文件更容易阅读。如果你关心实现细节,你可以打开 .inl 文件并读取它。如果你不这样做,你不必。

I like it because it separates the interface from the implementation and makes the header file a little easier to read. If you care about the implementation details, you can open the .inl file and read it. If you don't, you don't have to.

这篇关于.inl文件在C ++中的意义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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