发信人: sgq (老槐树), 信区: BorlandDev
标  题: Re: 求助 解释一程序错误提示
发信站: 哈工大紫丁香 (Tue Sep 17 18:01:24 2002) , 转信

程序实在太长了,实在很难看下去

从信息来看,估计是你犯了指针方面的错误

【 在 muzis (如果你是我的传说) 的大作中提到: 】
: 错误如下:
: waring:W8058 cannot create pre-compiled header: intitialized data in head ..

: error:Project File1.exe raised exception class EAccessViolation with mess ..

:       'Access vialation at address 0040c31A.Read of address 00000016'.
:       Process stopped.Use step or Run to continue.
: cpu windows.
:    0040c31A repnz scasb
:    0040c329 cld
: 源程序如下:             
: #include "animal.cpp"
: int main()     //
: {
:  list *List;
:  fact *F,*T;
:  rule *Rule,*R;
:  char ch[8];
:  int i=0;
:     Fact=NULL;
:     while(str[i])
:     {
:          F=new fact(i,str[i++]);
:          F->Next=Fact;
:          Fact=F;
:     }
:     F=Fact;
:     Fact=NULL;
:     while(F)
:     {
:          T=F;
:          F=F->Next;
:          T->Next=Fact;
:          Fact=T;
:     }
:     i=0;
:     ch[0]='R';ch[1]='U';ch[2]='L';ch[3]='E';
:     ch[4]='_';ch[5]='a';ch[6]='\0';
:     Rule=NULL;
:     for(i=0;i<15;i++)
:     {
:          R=new rule(ch,rulep[1],rulec[i]);
:          R->Next=Rule;
:          Rule=R;
:          ch[5]++;
:     }
:     R=Rule;
:     for(;;)             //咨询
:     {
:           i=R->Query();
:           if((i==1)||(i==-1))
:               break;
:           R=R->Next;
:           if(!R)
:               break;
:     }
:     if(!R)
:          cout<<endl<<"I don't know.";
:     cout<<endl<<"Press any bar to exit.";
:     getchar();
:     return True;
:  };
:  //ANIMAL.CPP文件
:  #ifndef ANIMAL_H
:  #define ANIMAL_H
:  #define True 1
:  #define False 0
:  #define Dontknow -1
:  #include <iostream.h>
:  #include <stdio.h>
:  #include <math.h>
:  #include <string.h>
:  char *str[]={"chew_cud","hooves","mammal","forward_eyes","claws",
: "pointed_teeth","eat_meat","lay_eggs","fly","feathers","ungulate",
:               "carnivore","bird","give_milk","has_hair","fly_well",
:               "black&white_color","can_swim","long_legs","long_neck",
:               "black_stripes","dark_spots","tawny_color","albatross",
:               "penguin","ostrich","zebra","giraffe","tiger","cheetah","\0 ..

:  int rulep[][6]={{22,23,12,3,0,0},{21,23,12,3,0,0},{22,19,20,11,0,0},
: {21,11,0,0,0,0},{17,19,20,13,-9,0},{17,18,13,-9,0,0},{16,13,0,0,0,0},
:                  {15,0,0,0,0,0},{14,0,0,0,0,0},{10,0,0,0,0,0},{8,7,0,0,0, ..

:                  {7,0,0,0,0,0},{4,5,6,0,0,0},{2,3,0,0,0,0,},{1,3,0,0,0,0} ..

:  int rulec[]={30,29,28,27,26,25,24,3,3,13,13,12,12,11,11,0};
:  class fact         //定义事实类
:  {
:       private:
:             int Number;
:             char Name[21];
:             int Active;
:             int Succ;
:       public:
:             fact *Next;
:             fact(int Num,char *L)
:                 {
:                   strcpy(Name,L);
:                   Number=Num;
:                   Active=False;
:                   Succ=DonKnow;
:                   Next=NULL;
:                 };
:             char *GetName()
:                 {
:                    char *L;
:                    L=new char[21];
:                    strcpy(L,Name);
:                    return L;
:                 }
:             int GetNumber()
:                 {
:                    return Number;
:                 }
:             int GetAct()
:                 {return Active;}
:             int GetSucc()
:                 {return Succ;}
:             void PutAct(const int Act0,int Succ0)
:                 {Active=Act0;Succ=Succ0;}
:  };
:   fact *Fact;
:  class list      //定义链类
:  {
:      private:
:          int Number;
:      public:
:           list *Next;
:           list(int Num)
:               {
:                 Number=Num;
:                 Next=NULL;
:                }
:           int GetNumber()
:               {return Number;}
:  };
:  class rule
:      {
:                char *LName;
:                list *Pre;
:                int Conc;
:           public:
:                rule *Next;
:                rule(char *N,int p[],int C);
:                ~rule();
:                int Quetry();
:                void GetName()
:                    {cout<<Name;}
:      };
:  rule::~rule()
:   {
:         List *L;
:         while (Pre)
:         {
:                 L=Pre->Next;
:                 delete Pre;
:                 Pre=L;
:         }
:         delete Name;
:   };
:   rule::rule(char *N,int P[],int C)
:   {
:         int i;
:         list *L;
:         Pre=NULL;
:         Next=NULL;
:         Name=new char[strlen(N)+1];
:         strcpy(Name,N);
:         i=0;
:         while(P[i]!=0)
:         {
:            L=new list(P[i++]);
:            L->Next=Pre;
:            Pre=L;
:         }
:         Conc=c;
:   };
:   int rule::Quesry()     //咨询函数
:   {
:         int i;
:         char c;
:         int Tag=0;
:         list *L;
:         fact *F;
:         L=Pre;
:         if(L==NULL) cout<<"\nError";
:         while(L!=NUll)
:         {
:            F=Fact;
:            for(;;)
:            {
:               if(abs(L->GetNumber())==F->GetNumber()) break;
:                 F=F->Next;
:            }
:            if(L->GetNumber()>0)
:            {
:                 if((F->GetSucc())==True) {L=L->Next;continue;}
:                 if((F->GetSucc)==False) return False;
:             }
:            else
:            {
:                 if((F->GetSucc)==True) return False;
:                 if((F->GetSucc())==False) {L=L->Next;continue;}
:            }
:             cout<<endl<<F->GetName()<<"(Y/N)";
:             c=getchar();
:             flushall();
:             if((c=='Y')||(c=='y'))
:             {
:                if(L->GetNumber()>0)
:                  F->PutAct(1, True);
:                if(L->GetNumber()<0)
:                  {
:                    F->PutAct(1, True)
:                    Tag=-1;
:                    return False;
:                  }
:             }
:             else
:             {
:                if(L->GetNumber()<0)
:                    {
:                       F->PutAct(1,True);
:                       Tag=-1;
:                       return False;
:                    }
:             }
:            L=L->Next;
:         }
:                 F=Fact;
:                 for(;;)
:                     {
:                        if(Conc==F->GetNumber()) break;
:                        F=F->Next;
:                     }
:                 if(Conc<24)
:                 {
:                    F->PutAct(1, True);
:                    return False;
:                 }
:                 if(Tag!=-1)
:                   {
:                     F=Fact;
:                     for(;;)
:                        {
:                          if(Conc==F->GetNumber())  break;
:                        }
:                   }
:                   if(Conc<24)
:                   {
:                      F->PutAct(1, True);
:                      return False;
:                   }
:                   cout<<"\nThis animal is"<<F->GetName();
:                   return False;
:   };
:   #endif




--

※ 来源:.哈工大紫丁香 http://bbs.hit.edu.cn [FROM: 202.106.139.110]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:203.350毫秒