这个程序编译没问题,就是执行的时候出错,哪位高手帮我看看的~~谢了
#include
class LinearStr{
int Size;
int Point;
char * * strp;
public:
LinearStr(int n=100)
{
if(n==0){
Size=Point=0;
strp=0;
}
else{
Size=n;
Point=0;
strp=new char * [n];
for(int i=0;i }
}
~LinearStr()
{
for(int i=0;i if(strp[i])delete[]strp[i];
delete []strp;
}
int Elem(char *p);
char * &Elem(unsigned n);
int Elem(void);
int Max(void);
void Print(void);
};
int LinearStr::Elem(char *p)
{
if(Point strp[Point++]=p;
return Point;
}
else{
char * *p1;
p1=new char * [++Size];
for(int i=0;i p1[i]=strp[i];
delete[]strp;
strp=p1;
strp[Point++]=p;
return Point;
}
}
char * &LinearStr::Elem(unsigned n)
{return strp[n-1];}
int LinearStr::Elem(void)
{return Point;}
int LinearStr::Max(void)
{return Size;}
void LinearStr::Print(void)
{
cout<<"输出字符串:\n";
for(int i=0;i cout<}
void main()
{
LinearStr a;
a.Elem("字符串指针数组的大小");
a.Elem("字符串指针数组中实际存在的元素个数");
a.Elem("指向字符串指针数组的指针");
cout<<"当前字符串的个数是:"< cout<<"当前字符串指针数组的大小是:"< cout<<"第二个字符串是:"< a.Print();
a.Elem(1u)="拼搏一下吧!";
a.Print();
}
--------------------next---------------------
阅读(1286) | 评论(0) | 转发(0) |