继续求救~~
//array.h
template<typename t>
class array
{public:
array(int s);
virtual~array();
virtual const t&entry(int index)const;
virtual void enter(int index,const t&value);
virtual void paixu();
protected:
int size;
t*element;};
template<typename t>array<t>::array(int s)
{if(s>1)size=s;
else size=1;
element=new t[size];
}
template<typename t>array<t>::~array()
{delete[]element;}
template<typename t>const t&array<t>::entry(int index)const
{return element[index];}
template<typename t>void array<t>::enter(int index,const t&value)
{element[index]=value;}
template<typename t>void array<t>::paixu()
{int i,work;
t&temp;
for(int pass=1;pass<size;pass++)
{work=1;
for(i=0;i<size-pass;i++)
if(element[i]>element[i+1])
{temp=element[i];
element[i]=temp;
element[i+1]=element[i];
work=0;}
if(work)break;}}
//cpp1
#include<iostream.h>
#include"12.h"
void main()
{array<int>a(5);
int i;
for(i=0;i<5;i++)
{cout<<"输入数据"<<endl;
int x;
cin>>x;
a.enter(i,x);}
a.paixu();
cout<<"排序后输出"<<endl;
for(i=0;i<5;i++)
cout<<a.entry(i)<<" ";
}
经过调试修改,结果只剩下以下两个错误~各位大大帮忙看看是怎么改
谢谢啦
Compiling...
Cpp1.cpp
d:\新建文件夹\12.h(32) : error C2530: 'temp' : references must be initialized
D:\新建文件夹\Cpp1.cpp(16) : while compiling class-template member function 'void __thiscall array<int>::paixu(void)'
执行 cl.exe 时出错.