<分区>
Possible Duplicate:
Why can templates only be implemented in the header file?
Why should the implementation and the declaration of a template class be in the same header file?
我是某所大学的计算机科学专业的学生,我们得到了用于硬件的文件。 而且我不确定这种实例化是如何工作的。
长代码短它看起来像这样。
在List.h中
#ifndef _LIST_H_
#define _LIST_H_
#include <iterator>
#include <ostream>
template <class T>
class List
/* implementation below but not relevant to this post */
.
.
.
.
....下面文件的最后几行。
#include "list.cpp"
#include "list_given.cpp"
#endif
并且List.cpp没有包含List.h
我不明白在头文件中包含 List.cpp 是如何工作的。