Templates spread across multiple files

前端 未结 3 1398
孤独总比滥情好
孤独总比滥情好 2020-12-18 18:43

C++ seems to be rather grouchy when declaring templates across multiple files. More specifically, when working with templated classes, the linker expect all method definitio

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-18 19:01

    When/if your compiler supports C++0x, the extern keyword can be used to separate template declarations from definitions.

    See here for a brief explanation.

    Also, section 6.3, "The Separation Model," of C++ Templates: The Complete Guide by David Vandevoorde and Nicolai M. Josuttis describes other options.

    alt text

提交回复
热议问题