.inl文件在C ++中的意义 [英] Significance of a .inl file in 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屋!