| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 636 人关注过本帖
标题:请问这段代码为什么编译正常,运行时却出错!
取消只看楼主 加入收藏
haitao9999
Rank: 2
等 级:论坛游民
帖 子:30
专家分:39
注 册:2006-4-10
结帖率:33.33%
收藏
已结贴  问题点数:15 回复次数:0 
请问这段代码为什么编译正常,运行时却出错!
include <iostream>
#include <vector>
using namespace std;

class counted{
    int id;
    static int count ;
public:
    counted():id(count++){
    cout<<id<<endl<<"it's being created"<<endl;
    }
    ~counted(){
    cout<<id--<<endl<<"it's being destroyed"<<endl;
    }
};

int counted::count = 0;

int main(){
    vector<counted*>  countArray;
    for(int i=0;i<5;i++)
        {
            if((countArray[i] = new counted)==0)
                cerr<<"内存申请失败";
    }
    return 1;
}
搜索更多相关主题的帖子: 编译 运行 代码 
2009-10-21 21:39
快速回复:请问这段代码为什么编译正常,运行时却出错!
数据加载中...
 
   



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

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