c++ template函数的声明和实现需要在同一个文件中

时间:2014-02-19 01:25:13   收藏:0   阅读:474

新建一个class C;生成2个文件C.h和C.cpp,在C.h中声明一个函数

template<class T>

T stringTo(char* str);

直接用VAssistX的Refactor-Create Implementation菜单,发现没有在C.cpp实现stringTo函数,而是在C.h中生成

template<class T>

T C<T>::stringTo(char* str)

{

}

 

网上说template修饰的函数,目前的编译器对于分开声明和实现的情况支持不是很好。。

原文:http://www.cnblogs.com/coolbear/p/3554343.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!