麻烦指导,谢谢
#include<iostream>
template<class elemType>
class Array{
public:
explicit Array(int size = DefaultArraySize);//这里有2处错误
Array(elemType *array,int array_size);
Array(const Array &rhs);
virtual ~Array(){delete []ia;}
bool operator==(const Array&) const;
bool operator!=(const Array&) const;
Array& operator=(const Array&);
int size() const {return _size;}
virtual elemType& operator[](int index){return ia[index];}
virtual void sort();
virtual elemType min() const;
virtual elemType max() const;
virtual int find(const elemType &value) const;
protected:
static const int DefaultArraySize = 0;
int _size;
elemType *ia;
};
int main(){
const int array_size=4;
Array<int> ia(array_size);
Array<double> da(array_size);
Array<char> ca(array_size);
for(int ix=0;ix<array_size;++ix)
{ia[ix]=ix;
da[ix]=ix*1.75;
ca[ix]=ix+'a';}
for(ix=0;ix<array_size;++ix)
{std::cout<<"["<<ix<<"] ia:"<<ia[ix]
<<"\tca:"<<ca[ix]<<"\tda:"<<da[ix]<<std::endl;
}
return 0;
}
这是编辑出的错误,共4处,麻烦大侠看看
1.'DefaultArraySize' : pure specifier can only be specified for functions
2.see reference to class template instantiation 'Array<double>' being compiled
3.'DefaultArraySize' : pure specifier can only be specified for functions
4.see reference to class template instantiation 'Array<char>' being compiled