.tcc文件

  It’s not standardised. Some use .tcc (t = template, cc = C++ source),some use .icc (i = included, cc = C++ source), some use .h (but that makes it indistinguishable from “real” headers), some just don’t use an extra file at all. It’s usually a file that contains implementations of templates declared in a header that then #includes the .tcc (or whatever) file. But as there is no standard nor a general consense about this, it could be anything else as well.It’s just an artifact of the need to have template definitions visible in all translation units that use them with most compilers:
example.hpp

#ifndef EXAMPLE_HPP
#define EXAMPLE_HPP

template< typename T > void f();

#include "example.tcc"

#endif

example.tcc

#ifndef EXAMPLE_HPP
# error Don't include this file directly, include example.hpp instead
#endif

template< typename T > void f()
{
// stuff
}

  非标准化的文件。就像经常使用的.tcc(t = template, cc = C++ source),.icc(i = included, cc = C++ source),.h(没法从“真正”的头文件中区分开来),有些根本不用额外的文件。这种文件中包含模版的声明和实现,通常用#include的方式包含。但由于没有标准,也没有一个普遍的意义,它可以是任何其他的东西。它只是需要模板定义在大多数编译器中使用的所有翻译单元中可见的产物。

你可能感兴趣的:(C/C++)