大神 undefined reference to 有关问题
请教各位大神 undefined reference to 问题
D:\DengYC\Projects\Vector1\Vector1.h|31|undefined reference to `Vector<int>::copyForm(int*, int, int)'|
#ifndef VECTOR_H
#define VECTOR_H
#define DEFAULT_CAPACITY 3
typedef int Rank;
template <typename T>class Vector
{
private:
Rank _size;
int _capacity;
T* _elem;
public:
// void expand();
// void shrink();
//
void copyForm(T* const A,Rank lo,Rank hi);
//
// bool bubble(Rank lo,Rank hi);
// void bubbleSort(Rank lo,Rank hi);
// void Vector<T> exchange(Rank i,Rank j);
// Rank selectMax(Rank lo,Rank hi);
// void merge(Rank lo,Rank hi);
// void mergeSort(Rank lo,Rank hi);
// Rank partition(Rank lo,Rank hi);
// void quickSort(Rank lo,Rank hi);
// void heapSort(Rank lo,Rank hi);
Vector(int c = DEFAULT_CAPACITY){_elem = new T[_capacity = c];_size = 0;}
Vector(T* A,Rank lo,Rank hi){copyForm(A,lo,hi);}//区间复制//
Vector(T* A,Rank n){copyForm(A,0,n);}//从头复制//
Vector(Vector<T> const& v,Rank lo,Rank hi){copyForm(v._elem,lo,hi);}//
Vector(Vector<T> const& v){copyForm(v._elem,0,v._size);}//
~Vector(){delete[] _elem;}//
//只读访问接口 相当于属性
// Rank size() const//
// {
// return _size;
// }
// bool empty() const {return _size<=0;}//
// int disordered() const;//
// Rank find(T const& e)const {return find(e,0,(Rank)_size);}//
// Rank find(T const& e,Rank lo,Rank hi)const;//
// Rank search(T const &e)const//
// {
// return (0>=_size)?-1:search(e,(Rank)0,(Rank)_size);
// }
// Rank search(T const& e,Rank lo,Rank hi)const;//
//
// //可写接口
T& operator[](Rank r)const;
// Vector<T>& operator=(Vector<T> const&)const;//
// T remove(Rank r);//
// int remove(Rank lo,Rank hi);//
// Rank insert(Rank r,T const&e);//
// Rank insert(T const&e){return insert(_size,e);}//
// void sort(Rank lo,Rank hi);//
// void sort(){sort(0,_size);}//
// void unsort(Rank lo,Rank hi);//
// void unsort(){unsort(0,_size);}//
// int deduplicate();//
// int uniquify();//
// //遍历
// void traverse(void(*)(T&)); //使用函数指针 只读或局部修改//
// template<typename VST> void traverse(VST&);//使用函数对象 可全局性修改//
};
#endif
#include "Vector1.h"
template <typename T> void Vector<T>::copyForm(T* const A,Rank lo,Rank hi)
{
_elem = new T[_capacity = 2*(hi-lo)];
_size = 0;
while(lo<hi)
_elem[_size++] = A[lo++];
}
template <typename T> T& Vector<T>::operator[](Rank i)const
{
return _elem[i];
}
#include <iostream>
#include "Vector1.h"
using namespace std;
int main()
{
int arr[4] = {1,2,3,4};
Vector<int> v1(arr,4);
return 0;
}
D:\DengYC\Projects\Vector1\Vector1.h|31|undefined reference to `Vector<int>::copyForm(int*, int, int)'|