更新时间:2022-01-23 19:43:19
使用
template <class T> IntArray<T>::IntArray(T s) throw() : Array<T>(s) {}
// ^^^ Use <T>
更重要的是,将实现也放在.h文件中.
More importantly, put the implemetation also in the .h file.
请参见为什么只能在头文件?.
我注意到的其他问题
T s
来确定大小没有意义. std :: size_t s
更有意义. IntArray
是类模板没有任何意义.使用它对我来说更有意义:
T s
for size. std::size_t s
makes more sense.It does not make sense that IntArray
is a class template. It makes more sense to me to use:
class IntArray : public Array<int> { ... };