課程內容摘要

  1. 89/2/23 (三):

    課程概述,要求, 測試, 第一次作業說明, C vs. C++ sample Three Bags of Balls

  2. 89/3/1 (三):

    2/23 測試之說明 (typedef, struct)

    Three Bags of Ball C++ 程式解說 (C++ 文法提要)

    VC 多檔案程式製作 Demo (project, workspace, #ifndef #endif #define, class manipulation)

  3. 89/3/6 (一):

    OOP 的特性, class 基本語法

    Abstract Data Type (ADT), Object based programming

    An abstract data type (ADT) is a data type that is organized in such a way that the specification of the objects and the specification of the operations on the objects is separated from the representarion of the objects and the implementation of the operations.

  4. 89/3/8 (三):

    C++ without class

  5. 89/3/13 (一):

    C/C++ programming styles: use function, naming, Global, format {brace, indent}

    物件設計 1

  6. 89/3/15 (三):

    malloc/free 的基本用法, 成對的特性, C++ 的 new/delete

    C++ 中如何運用建構元與解構元來做資源 (記憶體, 檔案...) 管理

    教務系統物件討論

    top-down 與 bottom-up 程式設計的基本概念, 各有不同的目的與要求

    門禁保全系統物件討論

    在 C++ 中 Three Bags of Balls 程式中物件架構如何建立出來

  7. 89/3/20 (一):

    C++ without class (continued)

    基本類別 (class) 定義

  8. 89/3/22 (三):

    為什麼要使用函式? 程式分工的原則

    基本類別 (class) 定義

    struct 與 class 的分別

    以類別為基礎的封裝

    建構元函式與解構元函式 (如何定義, 如何使用?)

    makefile 製作

    BC/TC 多檔案程式製作 Demo

    門禁保全系統作業說明

    類別的界面包含一組函式以及函式使用的順序

  9. 89/3/27 (一):

    繳交建立靜態物件架構的類別宣告

    說明如何規劃類別的界面

    解釋 IntArray 類別中的 1. operator[]() 函式 2. assert() macro

    簡單解釋多型在程式寫作時的目的: 抽象化的操作

  10. 89/3/29 (三):

    解釋為什麼 N 個物件我們不希望有 C(N,2) 種連線...不希望用全域物件

    OOP 程式設計時最主要的工作: 設計各個類別

    default constructor: 何時 compiler 會自動幫你加入預設的 default ctor

    必須使用 initialization list

    以物件作為函式呼叫之引數: C 裡結構變數的傳遞, 拷貝建構元, 預設的 bitwise copy

    靜態多型的意義 (page 138)

    class variable 與 class method (page 140)

    說明第二次程式作業

  11. 89/4/10 (一):

    作業繳交要求:class diagram

    封裝特性與 friend class/friend function

  12. 89/4/12 (三):

    繳交第二次程式作業

    visibility

    封裝與資料傳遞及物件內資料的設計

    iterator / friend class

    chaining (ctor, dtor, assignment operator)

  13. 89/4/17 (一):

    fstream

  14. 89/4/19 (三):

    繼承的特性

  15. 89/4/24 (一):

    繼承的功用 --- reuse

    composition (containment/construction) 與 inheritance 的差別

    virtual function I

    動態繫結 (binding) 與靜態繫結

    overriding vs. hiding vs. overloading

  16. 89/4/26 (三):

    常見的繼承錯誤: improper inheritance ---> composition

    界面重用是繼承很重要的特性, 同時它所帶來的好處也是使用繼承的主因: 假設我們重新寫一個類別, 並且沿用原來的界面 (使用相同的函式名稱,同樣個數的界面函式), 感覺上除了名稱改變了之外, 界面被你重複使用了, 可是這樣子卻不能得到 old code call new code 的好處, (old code 必須完全不做任何修改), 因為舊的程式中所使用的物件型態和你新的程式中新的類別型態是不一樣的, 根本連結不起來, 如果要連結起來的話, 必須透過作業系統, 以二進位的方式直接連結起來, 例如在 WIN32 中使用 DLL (Dynamic Linking Library) 實作驅動程式, 如此物件在適當地封裝下就已經導致相同界面的物件可以重用系統中舊的程式碼。 相對地,如果希望不透過二進位連結的機制的話, 就必須運用繼承的方法來重用界面。

    虛擬函式 (virtual function) -- 動態多型 (polymorphism) 中所使用的動態繫結技術就是達成上面界面重用時不須更改舊程式的主因。

    設計程式時發現可以做 factoring 的時候 (使用不同的物件的方法相同時,此時兩個物件的界面一定相同), 就是該使用繼承的時候
    例如: a. 人坐椅子, b. 視窗系統中 window manager 操作各種視窗, c. 繪圖系統中繪製各種各種形狀的物件, d. 作業系統 scheduler 操作各種行程, e. 作業系統中以 polling/interrupt 處理各種 IO 裝置, f. 人事室發薪水給所有員工 (包括各種職位的員工)

    proper inheritance -- substituibility

  17. 89/5/1 (一):

    8 puzzle 作業解釋:algorithm

    conioNT

  18. 89/5/3 (三):

    8 puzzle 作業解釋:object count (class variable), dump()

    new handler

    VC Debug mode memory leakage detection (Afxwin.h, use MFC as runtime DLL)

    improper inheritance example: bag of apples

  19. 89/5/8 (一):

    Advanced objects:

    Abstract Base Class: 是用來設計界面 (interface) 的, 繼承此 ABC 的所有類別的物件在這種 ABC 的指標下都需要是可以相互取代 (substitutible) 的

  20. 89/5/10 (三):

    Quiz #1: write a simple class

  21. 89/5/15 (一):

    const (基本型態,指標,物件)

    struct and enum declaration in a class

  22. 89/5/17 (三):

    物件行為的動態描述

  23. 89/5/22 (一):

    more on implementation of object states: the transition table

    chaining of dtor, ctor, and assignment operator ==> implicit vs. explicit

  24. 89/5/24 (三):

    more object characteristics:

    3 problems with traditional return value error handling

    exception handling mechanism

    pointer upcasting may change the address value

  25. 89/5/29 (一):

    namespace

    overriding vs. hiding vs. overloading (cont'd)

  26. 89/5/31 (三):

    overriding vs. hiding vs. overloading (cont'd)

    type conversion operators and type conversion constructor

    Run Time Type Information (RTTI)

  27. 89/6/5 (一):

    RTTI (cont'd)

    inheritance+overriding vs. composition+delegation

  28. 89/6/7 (三):

    fstream usages

    virtual function table revisited

    JAVA interface inheritance

  29. 89/6/12 (一):

    template function and template class

  30. 89/6/14 (三):

    Quiz

  31. 89/6/21 (三): 10:25-12:05 期末考

C++ 程式設計課程 首頁

製作日期: 01/10/2000 by 丁培毅 (Pei-yih Ting)
E-mail: pyting@cs.ntou.edu.tw