这个C++程序是怎么回事?!!哪错了

来源:百度知道 编辑:UC知道 时间:2024/06/28 03:32:52
#include <iostream>
using namespace std ;

template <class T>
class Array
{
private:
int size ;
T *head ;
T *allocate(int SIZE) ;
void error(char *s , int badindex=0 ) ;
public:
Array(int SIZE=0) ;
Array(const Array<T> &p) ;
~Array() ;
void reset(int arraylong) ;
T &operator[](int item) ;
operator T*(void) const ;
Array<T>& operator=(const Array<T> &p) ;
int getsize() const ;
};

template <class T>
void Array<T>::error( char *s ,int badindex )
{
cout<<"Errortype is :"<<s<<endl ;
if ( s=="IndexOutofRange" )
cout<<" the bad index is :"<<badindex<<endl ;
}

template <class T> //分配内存
T *Array<T>::allocate(int SIZE)
{
T *m=new T[SIZE] ;
if(m==NULL)
{

先把语法错误消灭了再传上来,最好把错误信息描述一下。

你把编译器给出的错误信息也贴上来,这样方便大家帮你查错。

麻烦你把没定义的变量先定义了再传上来…………