C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[701] [질문] EAccess Violation/프포
horong [ ] 8049 읽음    1998-11-06 22:46

  미치겠군요....

  EAccess Violation 에러가 계속 뜹니다...

  이거 어떻게 잡을수 없을까요?

  PLANE _fastcall QUEUE::Delete()
{
    LinkQueue* temp;

    // Because the first node is head node, do like below.
    temp=front->link;

    if(GetSize()>1)  front->link=temp->link; // Because of EAccess Violation.
    else  front->link=NULL;

    return temp->plane;//TempPlane;
}

  젤 아랬부분인데.....

  struct LinkQueue  {
    PLANE plane;
    LinkQueue* link;
};

  보시다시피 LinkQueue구조체는 위와같이 선언되었습니다...

  왜 이런상황에서......temp->plane;부분이 Access Violation 이라는 건지...

  이해가 돼질 않습니다...

  시간이 없습니다...

  가능한 빨리 답변해 주시기 바랍니다...

  무엇이 문제입니까~~~~~~~~~~~~~~~

  front->link=temp->link;도 Access Violation 에러가 났는데...

  약간 고쳐서 수정했습니다.....

  참고로 모든 코드를 올립니다.

  이부분이 클래수 부분입니다.

  링크드리스트로된 큐를 짜기위해서 QUEUE클래스에 속하는 구조체인 LinkQueue

  를 선언해놨습니다.



class PLANE  {
    public:
        _fastcall PLANE();
        void _fastcall SetReady(bool temp)  {  ready=temp;  }
        bool _fastcall GetReady()  {  return ready;  }
        void _fastcall SetFuel(int n)  {
            if(n>30)  fuel=30;
            else  if(n<0)  fuel=0;
            else  fuel=n;
        }
        int _fastcall GetFuel()  {  return fuel;  }
        void _fastcall DownFuel()  {  if(fuel>0)  fuel--;  }
        void _fastcall SetWaitingTime(int temp);
        int _fastcall GetWaitingTime()  {  return waiting_time;  }
    private:
        int ID;
        int fuel;
        bool ready;
        int waiting_time;
};

struct LinkQueue  {
    PLANE plane;
    LinkQueue* link;
};

class QUEUE  {
    public:
        _fastcall QUEUE();
        //~QUEUE();
        void _fastcall Add(PLANE item);
        PLANE _fastcall Delete();
        int _fastcall GetSize();
        bool _fastcall IsEmpty()  {
            if(front==rear)  return true;
            else  return false;
        }
        void _fastcall DownFuel();
        //void SetWaitingTime(int n);
        //int GetWaitingTime();
    private:
        LinkQueue *front,*rear;
};

  그리고 아랜 멤버 함수들입니다...

  급하게 짠거라 코드들이 좀 지저분합니다...



_fastcall PLANE::PLANE()
{
    ID=NumberOfPlanes++;
    randomize();
    fuel=random(30)+1;
    ready=false;
    waiting_time=NULL;
}

void _fastcall PLANE::SetWaitingTime(int temp)
{
    if(temp<0)  temp=-temp;
    waiting_time=temp;
}
//---------------------------------------------------------------------------

// Member functions of the Queue class.
_fastcall QUEUE::QUEUE()
{
    LinkQueue* temp=new LinkQueue;
    temp->link=NULL;

    front=temp;
    rear=temp;
}
/*
QUEUE::~QUEUE()
{
    LinkQueue* temp;

    do  {
        temp=front;
        front=front->link;
        delete temp;
    }while(front!=NULL);
}
*/
void _fastcall QUEUE::Add(PLANE item)
{
    // Special code.  Though, this code must be erased.
    // But for easy to coding, this code is allocated here.
    // Waiting time is equal to size of the queue.
    item.SetWaitingTime(GetSize());

    LinkQueue* temp=new LinkQueue;
    temp->link=NULL;
    temp->plane=item;

    rear->link=temp;
    rear=temp;
}

PLANE _fastcall QUEUE::Delete()
{
    LinkQueue* temp;

    // Because the first node is head node, do like below.
    temp=front->link;

    if(GetSize()>1)  front->link=temp->link; // Because of EAccess Violation.
    else  front->link=NULL;

    return temp->plane;//TempPlane;
}

  이상입니다...

  제발!~~수고좀 해주시기 바랍니다..



+ -

관련 글 리스트
701 [질문] EAccess Violation/프포 horong 8049 1998/11/06
707     [답변] HORONG/ EAccess Violation/프포 솔뫼마당 6038 1998/11/11
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.