定义一个arrary类头文件,然后运行text.cpp文件但是一直fatal error C1020: unexpected #endif 错误一直知指示头文件末尾#endif处错误 头文件array.h代码和text.cpp代码如下,求解答。所用编译器为VC++6.0
array.h头文件代码
#ifndef ARRARY_H
#define ARRARY_H
template
class Arrary {
private:
T*a;
int len;
int maxsize;
public:
Arrary(int size=100);
Arrary();Arrary()
int Length();
bool Append(T e);
bool GetItem(int i,T&e);
};
template
Arrary::Arrary(int size)
{
a=new T[size];
maxsize=size;
len=0;
}
template
Arrary::
{
delete[]a;
}
template
int Arrary::Length()
{
return len;
}
template
bool Arrary::Append(T e)
{
if(len==maxsize)
return falsse;
a[len]=e;
len++;
return true;
}
template
bool Arrary::GetItem(int i,T &e)
{
if(i<0 || i>len)
return true;
}
#endif
test.cpp代码
#include
#include"array.h"
using namespace std;
int main()
{
arrarya(10);
int e;
for (int i=0;i<10;i++)
a.Append(i+1);
i=0;
while(a.GetItem(i,e))
{
cout<<e<<" ";
i++;
}
cout<<endl;
return 0;
}