开发者

why template are defined in .h [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicates:

Why should the implementation and the declaration of a template class be in the same header file?

Why can templates only be implemented in the header file?

I'm not really understand why it's olbiged to define template implementation in a .h file?

Could someone give me a detail answ开发者_如何转开发er ?

Thanks!


Because the compiler needs the code to instantiate the template. If you put a template implementation into a .cpp file, you will be only able to instantiate the template in that .cpp file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜