順序表 反彙編的實現

2022-03-13 21:51:33 字數 2377 閱讀 8125

#include#include#define success           			 1 // 成功							

#define error -1 // 失敗

#define malloc_error -2 // 申請記憶體失敗

#define index_error -3 // 錯誤的索引號

template // 儲存的元素型別為 t_ele

class vector;

template vector::vector():m_dwinitsize(100), m_dwincrement(5)

template vector::vector(dword dwsize):m_dwincrement(5)

template vector::~vector()

template bool vector::expand()

// 3. 將資料複製到新的空間

for (dword i = 0; i < this->m_dwlen; i++)

//printf("*************************====\n");

// 4. 為各種屬性賦值

p_new_vector->m_dwlen = this->m_dwlen + this->m_dwincrement;

p_new_vector->m_dwindex = this->m_dwindex;

p_new_vector->m_dwincrement = this->m_dwincrement;

p_new_vector->m_dwinitsize = this->m_dwinitsize;

temp_pvector = this->m_pvector; //記錄當前容器指標的位址

this->m_pvector = p_new_vector->m_pvector; //將當前指標的位址指向新的容器指標的位址

return true;

}template dword vector::push_back(t_ele element)

//2.將新的元素複製到容器的最後乙個位置

this->m_pvector[m_dwindex] = element;

//3.修改屬性值

this->m_dwindex = this->m_dwindex + 1;

return success;

}template dword vector::insert(dword dwindex, t_ele element)

printf("目前的vector的容器指標位於: %x\n", this->m_pvector);

//2.判斷索引是否在合理區間

if (dwindex < 0 || dwindex > this->m_dwindex)

//3.將dwindex之後的元素後移

for (int i = dwindex; i < this->m_dwlen-1; i++)

//4.將element元素複製到dwindex位置

this->m_pvector[dwindex] = element;

//5.修改屬性值

this->m_dwindex = this->m_dwindex + 1;

return success;

}template dword vector::at(dword dwindex, t_ele* pele)

//將dwindex的值複製到pele指定的記憶體

*pele = this->m_pvector[dwindex];

return *pele;

}templatevoid vector::pop_back()

templatedword vector::capacity()

templatevoid vector::clear()

}templatebool vector::empty()

return true;

}templatedword vector::size()else

} return temp_vector_size;

}templatevoid vector::erase(dword dwindex)

//進行前移替換

for (int i = dwindex; i < this->m_dwindex; i--)

//修改屬性值

反彙編 函式的呼叫和實現 筆記

呼叫call時 會讓棧push 返回位址 相對就的 esp 4 進入call 後 先儲存 ebp 然後 把esp 給了ebp 當前函式堆疊從此開始 接下來 就是esp 減多少了.esp減多少就是這個函式的棧多大 從epb 開始加上這個值就是這個函式所用棧的範圍.如果沒變數 esp 不減,如果有1個i...

C 類的反彙編

c 的類與c 的結構體本質上沒有什麼不同,唯一不同的可能即是在編譯期預設的成員訪問全鄉不同。當我們new 乙個類時,在heap中申請了一塊記憶體區域,用於儲存類的實體,並且呼叫了類的建構函式。當我們呼叫delete時,呼叫了析構函式,並呼叫了heap記憶體塊釋放函式。今天隨便寫了乙個簡單的類,並對其...

反彙編的call和retn

call指令 call指令可不是如喚指令,而是子程式呼叫指令。那麼組合語言中的子程式是什麼呢?子程式能被其它程式呼叫,在實現某種功能後能自動返回到呼叫程式去的程式。其最後一條指令一定是返回指令,故能保證得新返回到呼叫它的程式中去。也可呼叫其它子程式,甚至可自身呼叫。我們可以暫時把子程式理解為乙個 段...