為何在執行之後會出現error的訊息 |
尚未結案
|
valkyriedx
一般會員 發表:2 回覆:0 積分:0 註冊:2005-03-02 發送簡訊給我 |
Error訊息:
Project Project1.exe raised exception class #AccessViolation with message 'Access violation at address 00401B66 in module 'Project.exe'. Read of address 00000000'.Process stopped. Use Step or Run to contiune. 以下是程式的一部份,Run的時候沒有錯誤,可是當呼叫insert_node,執行到while的時候會出現上列Error的訊息,請問這個訊息代表什麼意義,程式有哪裡需要修改? class node
{
friend class list; // 宣告 list 類別為 node 類別的夥伴類別
unsigned int pix;
unsigned char data;
short c;
node *link;
};
// --------------------------------------
class list
{
private:
node *front; // front 為一個 node 指標,它指向單向鏈結串列的前端
node *mid;
node *prev;
public:
list();
~list();
bool empty();
void insert_node(unsigned int key,unsigned char value);
void delete_node();
void getdata();
void print();
void paste();
void re_mid();
};
// ---------------------------------------------------
list::list(void) // Constructor
{
front = new node;
mid = new node;
prev = new node;
front->link = NULL;
mid->link = NULL;
prev->link = NULL;
}
list::~list(void) // Destructor
{
node *this_node, *temp_node;
if(front->link != NULL)
{
this_node = front->link;
while(this_node->link != NULL)
{
temp_node = this_node;
this_node = this_node->link;
delete temp_node;
}
delete this_node;
}
delete front;
delete mid;
}
// ----------------------
// 判斷是否為空串列
// ----------------------
bool list::empty(void)
{
if(front->link == NULL) // 空串列
return true;
else
return false;
}
// --------------------------------------------------------
// 將資料(key)插入單向鏈結串列中,並按小至大順序排列
// -------------------------------------------------------- void list::insert_node(unsigned int key,unsigned char value)
{
const short A=3,D=1,doorsill=30;
short flag,delta;
node *new_node, *this_node;
new_node = new node;
new_node->pix = key;
new_node->data = value;
new_node->c = A*1-D;
new_node->link = NULL;
if(empty())
{ // 空串列,插入第一個節點到front之後
front->link = new_node;
mid->link = new_node;
}
else
{
flag=0;
this_node = mid->link;
if(this_node->pix >= key && this_node->data > value)
{
if(front->link == mid->link)
{
front->link = new_node;
new_node->link = this_node;
}
else
{
prev->link = new_node;
new_node->link = this_node;
}
flag=1;
}
else if(this_node->pix == key && this_node->data == value)
{
this_node->c = this_node->c + A*1-D;
flag=1;
} if(flag==1)
{
prev = this_node;
this_node = this_node->link;
} while(this_node->pix == key)
{
if(this_node->data < value && flag==0)
{
prev->link = new_node;
new_node->link = this_node;
flag=1;
} if(abs(key-this_node->data) < doorsill)
{delta = 1;}
this_node->c = this_node->c A*delta-D;
delta=0;
if(this_node->data == value)
{flag=1;}
prev = this_node;
this_node = this_node->link;
}
if(flag == 0)
{
prev->link = new_node;
new_node->link = this_node;
flag=1;
}
if(this_node->link == NULL && flag == 0)
{
this_node->link = new_node;
mid->link = new_node;
}
mid->link = this_node; }
} // -------------------------------------
// 重置mid
// -------------------------------------
void list::re_mid(void)
{
mid->link = front->link;
prev->link = front->link;
}
//---------- 用timer執行下段程式(間隔1秒) for (int i=105;i<115;i )
for (int j=0;j
|
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
您好:PO程式碼的方式請參考版規,煩請修改謝謝您的配合 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=47262 AccessViolation表示您違規存取到某位置的記憶體
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |