首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

把程序贴出来,求大神们指导。不知道哪里出错了。该怎么解决

2012-03-21 
把程序贴出来,求大神们指导。。。。不知道哪里出错了。。。。C/C++ code#include time.h#include iostream#ifn

把程序贴出来,求大神们指导。。。。不知道哪里出错了。。。。

C/C++ code
#include <time.h>#include <iostream>#ifndef ROOM_H_#define ROOM_H_#include <iostream>#include <string>using namespace std;class Building{public:    void static ResetBuildingInfo() {visited=0;capacity=Init(0);prinloc=Init(capacity);}    static int Init(int i){        srand(time(NULL));        if(i==0)   return rand()%10+5;   //get the random room capacity 5 to 15        else return rand()%i+1;  //get the random princess location 1 to the max room number    }    static int visited;  //the number of the room aleady been visited    static int capacity;    static int prinloc;};int Building::visited(0);int Building::capacity(Init(0));int Building::prinloc(Init(Building::capacity));class Room:public Building{public:    Room(int nm, int flr, int in, Room* from):name(nm),floor(flr){        exists=ExistsInit();        InitExits(in);        for(int i=0;i<6;i++) pexits[i]=NULL;        pexits[5-in]=from;    }    int ExistsInit(){            if(name==prinloc) return 3;        srand(time(0));        int ex=rand()%3;        if(ex<2) return 0;        else return 1;    }    void InitExits(int in){        for(int i=0;i<6;i++) exits[i]=0;        if(in>=0) exits[5-in]=1;    }protected:    int const name;    int const floor;    int exits[6]; //0_nouth, 1_east, 2_up, 3_down, 4_west, 5_south    Room *pexits[6]; //pointing to the other room    int exists; //0_empty, 1_monster, 2_princess};class Lobby:public Room{public:        Lobby():Room(0,0,-1,NULL){        for(int i=0;i<6;i++) pexits[i]=NULL;    }};#endif //define ROOM_H_int main(){    while(1){        char i;        int envi;        Lobby lob;        cin>>i;    }}


这怎么就不能运行了呢?

[解决办法]
main函数, 返回值都没有
[解决办法]
可以运行的,只是没有输出
[解决办法]
在构造函数里面写一下测试数据
[解决办法]
我用vc6,vs2005测试 程序都OK 啊

热点排行