新微赢技术网
标题:
请教c++高手。调试的内存问题
[打印本页]
作者:
ˇ风逍遥ˇ
时间:
2009-11-6 00:53
标题:
请教c++高手。调试的内存问题
我写了个学生管理的,可以插入,删除,查看。我调试时,它没有找到错误。但当我添加了一个学生资料后,再查看全部或者删除这位学生的资料时就说内存出错,请教一下各位c++高手该如何修改。代码如下:
#include <iostream>
#include <string>
using namespace std;
class roll
{
private: //学生会成员属性
long int _id; // 学号
string _name; //姓名
string _sex; //性别
string _brithday; //出生日期
string _look; //政治面貌
long int _num; //联系电话方式
string _address; //家庭住址
public:
roll(long int id,string name,string sex,string brithday,string look,long int num,string address) //构造函数
{
_id=id;_name=name;_sex=sex;_brithday=brithday;_look=look;_num=num;_address=address;
}
long int Id() {return this->_id; }
string Name() {return this->_name;}
string Sex() {return this->_sex;}
string Brithday() {return this->_brithday; }
string Look() {return this->_look;}
long int Num(){return this->_num;}
string Address() {return this->_address;}
};
int main()
{
roll *member[50];
member[0]=new roll(1234567,"王1","男","11/14/1987","共青团员",36901234,"广东广州");
member[1]=new roll(2345678,"王2","女","12/14/1987","党员",36902345,"广东佛山");
member[2]=new roll(3456789,"王3","男","1/14/1987","共青团员",36903456,"广东深圳");
member[3]=new roll(4567890,"王4","女","2/14/1987","党员",369045678,"广东东莞");
member[4]=new roll(5678901,"王5","男","3/14/1987","共青团员",36905678,"广东中山");
int n=1;
int m=3;
while(n!=0)
{
cout < <"请选择你要进行的操作:" < <endl; //选择你要进行的操作
cout < <"插入学生的基本信息请选择-1" < <endl;
cout < <"删除学生的基本信息请选择-2" < <endl;
cout < <"输出基本信息数据项请选择-3" < <endl;
cout < <"退出请选择-0" < <endl;
cin>>n;
m++;
switch (n)
{
case 1:
{ string nname;
string ssex;
string bbrithday;
string llook;
long int nnum,iid;
string aaddress;
cout < <"输入学号:" < <endl;
cin>>iid;
cout < <"输入姓名:" < <endl;
cin>>nname;
cout < <"输入性别:" < <endl;
cin>>ssex;
cout < <"输入出生日期:" < <endl;
cin>>bbrithday;
cout < <"输入政治面貌:" < <endl;
cin>>llook;
cout < <"输入联系电话方式:" < <endl;
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2