错在倒数第三行,不知是什么错
高手帮帮忙#include<iostream.h>
class c
{
int l;
char *p;
public:
c(int i=0)
{
l=i;
p=new char [l];
}
char operator[](int)
{
int i;
static char ch;
if(i<l && i>=0)
return p[i];
else {cout<<"index is out of range"<<endl;return ch;}
}
};
void main()
{
int j;
c s1(6);
char *st="string";
for(j=0;j<8;j++)
s1[j]=st[j];
for(j=0;j<8;j++)
cout<<s1[j];
}