[英]C++ - compilation error
I am implementing a vector, and for some reason, my header file keeps saying this error: 我正在实现矢量,并且由于某种原因,我的头文件一直在说此错误:
error C2590: 'CopyValues' : only a constructor can have a base/member initializer list
see reference to class template instantiation 'Vector<T>' being compiled
error C2533: 'Vector<T>' : constructors not allowed a return type
error C2760: syntax error : expected '{' not ';'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2039: 'GetNewCapacity' : is not a member of 'Vector<T>'
Here's my header: 这是我的标题:
template <class T>
class Vector
{
public:
typedef T* Iterator;
Vector(HeapAllocator* allocator);
Vector(HeapAllocator* allocator, size_t size);
~Vector();
size_t capacity();
size_t size();
bool empty();
void clear();
Iterator insert(Iterator position, const T& value);
void insert(Iterator position,size_t n, const T& value);
void insert(Iterator position,Iterator first, Iterator last);
void erase();
void resize(size_t numElements);
void push_back(const T& item);
void pop_back();
private:
void CopyValues(Iterator pBegin, Iterator pEnd, Iterator pTarget): // when I comment out this method, it compiles fine, why?
size_t GetNewCapacity(size_t currentCapacity);
T* mBegin;
T* mEnd;
T* mCapacity;
HeapAllocator* mAllocator;
};
Im staring blindly at the code, but I can't find any syntax error. 我盲目地盯着代码,但是我找不到任何语法错误。 What is causing this? 是什么原因造成的?
用该行末尾的:代替;
void CopyValues(Iterator pBegin, Iterator pEnd, Iterator pTarget):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.