Why use a “tpp” file when implementing templated functions and classes defined in a header?

后端 未结 3 1722
礼貌的吻别
礼貌的吻别 2020-12-05 07:27

Please refer to the first answer in this question about implementing templates.

Specifically, take note of this quote

A common solution to thi

3条回答
  •  悲&欢浪女
    2020-12-05 08:12

    Files extensions are meaningless to the preprocessor; there's nothing sacred about .h either. It's just convention, so other programmers know and understand what the file contains.

    The preprocessor will allow you to include any file into any translation unit (it's a very blunt tool). Extensions like that just help clarify what should be included where.

提交回复
热议问题