篇名 | 使用C與C++以檢驗陣列註標越界之比較 |
---|---|
卷期 | 30 |
並列篇名 | Comparison between C and C++ in Examining the Data Range for the Indexes of the Array Variables |
作者 | 許金童 |
頁次 | 075-080 |
關鍵字 | 陣列變數 、 註標 、 越界 、 物件導向 、 類別 、 array variable 、 index 、 overloading 、 object-oriented programming 、 class |
出刊日期 | 201012 |
本文探討有關電腦基礎課程的計算機程式之教學中,使用C/C++語言來宣告陣列變數時,由於各種版本之C/C++編譯程式,都未對陣列變數的註標值,進行資料範圍的檢驗[1][2],因此程式設計者必須自行撰寫註標值之範圍檢驗的段落敘述,以防止註標值越界所造成的邏輯錯誤,C++包含了C的大部份功能,而且又發展了不少新的指令使用法,本文擬將檢驗註標值範圍的程式設計方法,做C與C++之比較,最後並使用物件導向技術,處理這個問題。
This article discusses something about computer programming. None of the versions of C/C++ compilers has the functions to examine the data range for the indexes of the array variables. Therefore, when programmers declare the array variables in C/C++, they have to program some paragraphs about examining the data range so as to prevent the logic errors in overloading of the indexes. C++ includes C in most of functions, and has been developed many new commands. This article intends to compare C with C++ in examining the data range for the indexes of the array variables, and finally, use the object-oriented programming technique to deal with the above mentioned problems.