std::string类型的值不正确的初始化导致异常

std::string sTst(0);定义的时候因为不正确的初始化导致程序异常!

原因:构造函数std::string::string(char* lpszBuff)中可能进行了字符串拷贝操作,因为构造的时候传入了0【NULL】导致程序停止运行!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
/数据结构课程设计--飞机场模拟--初始化及主程序 //舞动青春--张佳贵 //2009年6月 #include #include #include"Extended_queue.h" #include"Random.h" #include"Runway.h" #include"Plane.h" using namespace std; void run_idle(int time) { cout<<" "<<time<<":Runway is idle."<<endl; } //初始化程序 void initialize(int &end_time,int &queue_limit,double &arrival_rate,double &departure_rate){ cout<<"This is program simulates an airport with only one runway."<<endl <<"One plane can land or depart in each unit of time."<<endl; cout<<"Up to what number of planes can be waiting to land" <<" or take off at any time?"<>queue_limit; //输入用户期望的跑道最大容纳量 cout<<"How many uints of time will the simulation run?"<>end_time; bool acceptable; do { cout<<"Expected number of arrivals per uint time?"<>arrival_rate; cout<<"Expected number of departures per uint time?"<>departure_rate; if(arrival_rate<0.0||departure_rate<0.0) cerr<<"These rates must be nonnegative."<1.0) cerr<<"Safety Warning:This airport will become saturated."<<endl; }while(!acceptable); } //主程序 int main() { int end_time; int queue_limit; int flight_number=0; double arrival_rate; double departure_rate; initialize(end_time,queue_limit,arrival_rate,departure_rate); //初始化跑道信息 Random variable; //定义随机数变量 Runway small_airport(queue_limit); //判断当前发出请求的飞机是否应该被接受或拒绝 for(int current_time=0;current_time<end_time;current_time++){ int number_arrivals=variable.poisson(arrival_rate); for(int i=0;i<number_arrivals;i++){ Plane current_plane(flight_number++,current_time,arriving); if(small_airport.can_land(current_plane)!=success) current_plane.refuse(); } int number_departures=variable.poisson(departure_rate); for(int j=0;j<number_departures;j++){ Plane current_plane(fligh

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值