标题:程序有点错误 就是找不出来 请帮帮忙
取消只看楼主
tianxiaogang
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2005-10-23
 问题点数:0 回复次数:0 
程序有点错误 就是找不出来 请帮帮忙

#include "string.h"
class A
{
public:
A(int,int);
~A();
bool panduan(char*)const;
void Add(char*);
void display();
private:
int m;
//static int m;
char**s;
int _count;
};
//int A::m=0;
A::A(int count,int m1)
{
m=m1;
_count=count;
s=new char*[_count];
}
A::~A()
{
for(int i=0;i<_count;i++)
delete s[i];
delete[] s;
}
bool A::panduan(char*p)const
{
bool h=false;
for(int k=0;k<_count;k++)
{
if(s[k]==p)
{
h=true;
break;
}
}
return h;

}
void A::Add(char*p)
{
if(!panduan(p))
{
if(m<=_count)
{
s[m]=new char[strlen(p)];
strcpy(s[m],p);
m++;
}
else
cout<<"已经满了"<<endl;
}
}
void A::display()
{
for(int j=0;j<_count;j++)
cout<<s[j]<<endl;
}

这是 头文件

#include <iostream.h>
#include "tou.h"
int main()
{
A a(3,0);
a.Add("abcd");
a.Add("lp");
a.Add("qqqqoooo");
//a.Add("ttt");
a.display();
return 0;
}

当运行时 可以输出但是 跳出来一个窗口说什么


搜索更多相关主题的帖子: private display include public count 
2005-12-11 11:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-37764-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.081380 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved