100 likes | 193 Views
Concept of C++ and MFC. Speaker : Wei-Lu Lin. Advisor : Ku-Yaw Chang. Outline. Instance and Instantiation Constructor vs. Destructor Malloc /Free vs. New/Delete Data Exchange and Data Vaidation. Instance and Instantiation. Instance
E N D
Conceptof C++ and MFC Speaker: Wei-Lu Lin Advisor : Ku-Yaw Chang
Outline • Instance and Instantiation • Constructor vs. Destructor • Malloc/Free vs. New/Delete • Data Exchange and Data Vaidation
Instance and Instantiation • Instance • An individual object of a certain class. While a class is just the type definition, an actual usage of a class is called an "instance". Instantiation iPhonedesign drawing Factory iPhones
Instance and Instantiation • Instantiation • it is when you create an instance of a variable • For example: • inti ; • int *pInt =new int;
Constructor vs. Destructor • Constructor • a special function • is invoked when the object is created • can be a lot of constructors • name has to be as class name • Class Time{ Public: Time() {cout<<“正在執行Time建構函式”}; } ;-> Time object_1; When you create a object_1 , the constructor will be invoked .
Constructor vs. Destructor • Destructor • a special function • is called when a object is destroyed • just a destructor • “~”+ class name • Class Time{ Public: Time() {cout<<“正在執行Time建構函式”}; ~Time() {cout<<“正在執行Time解構函式”}; } ; -> Time object_1;
Constructor vs. Destructor • If you don’t use the object_1, then the destructor will be called after you create object_1.
New/Deletevs. Malloc/Free • New/Delete • belong to C++ • new =malloc+constructor ; delete=free+destructor • Ex: int *p=new int[10] ; delete[ ] p; • Malloc/Free • belong to C • malloc / free • Ex: int *p=(int*) malloc (10*sizeof(int)) ; free(p);
Data Exchange and Data Validation • DDX • 將使用者設定於DialogBox控制項的資料,與程式內所對應的Dialog Box物件之屬性,進行資料交換。 • DDV • 檢查由使用者輸入至Dialog Box控制項內的資料是否正確,若違反檢查規則,則自動顯示警告訊息方塊。