网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
06月15日漏签0天
c++吧 关注:619,509贴子:2,111,387
  • 看贴

  • 图片

  • 吧主推荐

  • 游戏

  • 2回复贴,共1页
<<返回c++吧
>0< 加载中...

"0x0042b190"指令引用的"0x00000000"内存。该内存不能为"read

  • 只看楼主
  • 收藏

  • 回复
  • 喜欢天蓝色海
  • ,
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include <string>
#include<fstream>
#include<iostream>
#include<algorithm>
#include<vector>
//#include<stdlib>
using namespace std;
/*------------------------------------部门类定义---------------------------------------*/
class Department
{
private:
string Dname;
string Daddress;
string Dgovernor;
string Dphone;
public:
Department(string Dname=" ",string Daddress=" ",string Dgovernor=" ",string Dphone=0);
~Department(){}
void Insert();
void Change();
string GetDname();
string GetDaddress();
string GetDgovernor();
string GetDphone();
void Writefile(fstream &file);
void Readfile(fstream &file);
void Output();
};
Department::Department(string Dname,string Daddress,string Dgovernor,string Dphone)
{
this->Dname=Dname;
this->Daddress=Daddress;
this->Dgovernor=Dgovernor;
this->Dphone=Dphone;
}
void Department::Insert()
{
cout<<"请输入部门信息(部门名称--------部门地址--------部门负责人------部门负责人联系电话):"<<endl;
cin>>Dname>>Daddress>>Dgovernor>>Dphone;
}
void Department::Change()
{
bool exitFlag=false;
int choice;
while(!exitFlag)
{
cout<<"请选择要修改的属性(1~4) "<<endl;
cout<<"1:部门名称 2:部门地址 "<<endl;
cout<<"3:部门负责人 4:部门负责人联系电话 "<<endl;
cin>>choice;
switch(choice)
{
case 0:
exitFlag=true; break;
case 1:
cout<<"请输入部门名称:";
cin>>Dname;
break;
case 2:
cout<<"请输入部门地址:";
cin>>Daddress;
break;
case 3:
cout<<"请输入部门负责人:";
cin>>Dgovernor;
break;
case 4:
cout<<"请输入部门负责人联系电话:";
cin>>Dphone;
break;
}
}
}
string Department::GetDname()
{
return Dname;
}
string Department::GetDaddress()
{
return Daddress;
}
string Department::GetDgovernor()
{
return Dgovernor;
}
void Department::Writefile(fstream &file)
{
file<<Dname<<" "<<Daddress<<" "<<Dgovernor<<" "<<Dphone<<endl;
}
void Department::Readfile(fstream &file)
{
file>>Dname>>Daddress>>Dgovernor>>Dphone;
}
void Department::Output()
{
cout<<"部门名称--------部门地址--------部门负责人------部门负责人联系电话):";
cout<<Dname<<" "<<Daddress<<" "<<Dgovernor<<" "<<Dphone<<endl;
}
/*_____________________________________________________________________________________*/
class System
{
private:
vector<Department> v1;
vector<Department>::iterator iter1;
Department a;
fstream file1;
fstream file2;
void Save1();
public:
System();
void Insert();
void Change();
void Search();
void Output();
void Interface();
};
void System::Save1()//从文件中读出放到容器里
{
file1.open("Department1.txt",ios::in);
if(!file1)
{
cout<<"file open error!"<<endl;
abort();
}
while(!file1.eof())
{
a.Readfile(file1);
v1.push_back(a);
}
file1.close();
}
System::System()
{
cout<<"de";
Save1();
}
void System::Insert()
{
bool exitFlag=false;
char choice;
file2.open("Department2.txt",ios::out|ios::app);
if(!file2)
{
cout<<"file open error!"<<endl;
abort();
}
a.Insert();
v1.push_back(a);
iter1=v1.begin();
while(iter1!=v1.end())
{
(*iter1).Writefile(file2);
iter1++;
}
while(!exitFlag)
{
cout<<"请选择是否继续输入(y/n) : ";
cin>>choice;
switch(choice)
{
case 'y':
//Employee b;
a.Insert();
v1.push_back(a);
iter1=v1.begin();
while(iter1!=v1.end())
{
(*iter1).Writefile(file2);
iter1++;
}
break;
case 'n':
file2.close();
exitFlag=true;
break;
}
}
}
void System::Change()
{
string name;
bool exitFlag=false;
file2.open("Department2.txt",ios::out|ios::app);
if(!file2)
{
cout<<"file open error!"<<endl;
abort();
}
cout<<"请输入部门名称 :";
cin>>name;
for(iter1=v1.begin();iter1!=v1.end();iter1++)
{
if(iter1->GetDname()==name)
{
iter1->Change();
iter1=v1.begin();
while(iter1!=v1.end())
{
(*iter1).Writefile(file2);
iter1++;
}
file2.close();
}
else
cout<<"not found!"<<endl;
}
}
void System::Search()
{
string name;
cout<<"请输入要查找的部门名称:";
cin>>name;
for(iter1=v1.begin();iter1!=v1.end();iter1++)
{
if(iter1->GetDname()==name)
iter1->Output();
else
cout<<"not found!"<<endl;
}
}
void System::Output()
{
for(iter1=v1.begin();iter1!=v1.end();iter1++)
iter1->Output();
}
void System::Interface()
{
int temp;
cout<<"\t\t ********************欢迎使用********************"<<endl;
cout<<"\t\t ****************企业员工信息管理系统****************"<<endl;
cout<<"\t\t 1.信息录入 "<<endl;
cout<<"\t\t 2.信息修改 "<<endl;
cout<<"\t\t 3.信息查询 "<<endl;
cout<<"\t\t 4.信息输出 "<<endl;
cout<<"\t\t 5.退出! "<<endl;
cout<<"\t\t 请您选择(1~5):";
cin>>temp;
switch(temp)
{
case 1:
Insert();
break;
case 2:
Change();
break;
case 3:
Search();
break;
case 4:
Output();
break;
case 5:
exit(0);
}
}
void main()
{
System s;
s.Interface();
}


  • 喜欢天蓝色海
  • ,
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
拜托各位大神帮帮忙!拜托了!


2025-06-15 09:20:22
广告
  • 喜欢天蓝色海
  • ,
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
主函数压根儿就不能执行呀!为什么?


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 2回复贴,共1页
<<返回c++吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示