请教各位大神 undefined reference to 问题
#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)'|
相关推荐
undefined reference to 'pthread_create'的解决方法
undefined reference to 'pthread_create'的解决方法,需要的朋友可以参考一下
undefined reference to ‘pthread_create’的解决方法
照着GUN/Linux编程指南中的一个例子输入编译,结果出现如下错误: undefined reference to ‘pthread_create’undefined reference to ‘pthread_join’ 问题原因: pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a,所以在使用pthread_create()创建线程,以及调用 pthread_atfork()函数建立fork处理程序时,需要链接该库。 问题解决: 在编译中要加 -lpthread参数 gcc thread.c -o thread -lpthr
undefined reference to `SetPduPowerConsumptionCnt'错误的解决方法
编译时出现undefined reference to `SetPduPowerConsumptionCnt'错误要如何解决呢?有没有什么好的解决方法?下面小编就为大家解答吧,如果你也遇到了这种情况,可以过来参考下
【转】undefined reference to错误的解决方法.doc
【转】undefined reference to错误的解决方法.doc
C生成静态库给C++调用出现undefined reference to ...解决方案_cpp
C生成静态库给C++调用出现undefined reference to ...解决方案 已经写好makefile,还有头文件,看注释,基本没问题的



