Microsoft PowerPoint - 13_Exception.ppt

Size: px
Start display at page:

Download "Microsoft PowerPoint - 13_Exception.ppt"

Transcription

1 1 第 13 章例外處理 (Exception Handling) 13.1 簡介 13.2 例外處理概觀 13.3 其它錯誤處理技術 13.4 簡單的例外處理範例 - 除 0 錯誤 13.5 重新丟出例外 13.6 函式例外清單 13.7 處理非預期例外 13.8 堆疊返回 13.9 建構子, 解構子, 與例外處理 例外與繼承 處理新的錯誤 auto_ptr 類別與動態記憶體配置

2 簡介 例外 表示程式出問題 發生不正常情況 程式停止執行 例外處理 解決例外情況 程式可以繼續執行 - 可容許錯誤 例如 : 可處理程式除 0 錯誤

3 例外處理概觀 術語 (Terminology) 丟出例外 (throws an exception) 函式遇到錯誤 例外處理程式 (Exception handler) 捕捉及處理例外 假如沒有例外處理程式捕捉適當例外 程式將可能中斷執行

4 例外處理概觀 C++ 程式 try { 可能丟出例外的程式碼使用 throw 丟出例外, 可丟出任何資料型態的物件通常丟出 exception 物件 } catch (exceptiontype1){ 處理例外的程式碼 } catch (exceptiontype2){... }

5 簡單的例外處理範例 : 除 0 錯誤 例外類別 基礎類別 exception, 引用 <exception> 建構子可接受一個字串 用來描述例外 成員函式 what() 會傳回該字串 衍生類別 runtime_error, logic_error bad_alloc, bad_cast, bad_typeid

6 例外處理概觀 捕捉所有例外類別 catch (...) catch (exception &anyexception) 捕捉特定例外類別 catch (MyException &myex) catch ( bad_alloc &memallocationex ) catch ( runtime_error &error )

7 例外處理概觀 在 try 區塊內 假如發生例外 程式會跳過 try 區塊內還沒執行的程式 進入適當的 catch 區塊 假如沒有例外處理程式可用 函式結束 尋找較上層的 catch 區塊 如果沒有例外 執行完 try 區塊 跳過 catch 區塊

8 其它錯誤處理技術 忽略例外 - 程式可能不正常結束 終止程式執行 設定錯誤指示燈 呼叫 exit () - <cstdlib> 跳到外層處理錯誤 - 破壞程式結構 setjump and longjump - <csetjmp> 專屬的錯誤處理程式 例如 : new 有專屬錯誤處理程式

9 簡單的例外處理範例 : 除 0 錯誤 範例程式 定義新的例外類別 DivideByZeroException 繼承 exception 類別 處理除 0 錯誤

10 簡單的例外處理範例 : 除 0 錯誤 在除法函式中 測試分母 假如分母為零, 丟出例外 在 try 區塊內 呼叫除法函式 catch DivideByZeroException 例外物件 遇到除 0 錯誤, 程式可繼續執行

11 1 // Fig. 13.1: fig13_01.cpp 2 // 一個簡單的例外處理範例程式 3 // 用來檢查除 0 例外 4 #include <iostream> 5 6 using std::cout; 7 using std::cin; 8 using std::endl; 9 10 #include <exception> using std::exception; // 定義一個例外類別 :DivideByZeroException 15 // 當發生除 0 錯誤時可丟出此類例外 16 class DivideByZeroException : public exception { public: // 建構子 : 直接實作, 指定錯誤訊息 21 DivideByZeroException::DivideByZeroException() 22 : exception( "attempted to divide by zero" ) {} }; // end class DivideByZeroException 25 Outline fig13_01.cpp (1 of 3) 2003 Prentice Hall, Inc. All rights reserved. 11

12 26 // 執行除法動作 27 // 如果除數為 0, 則丟出 DivideByZeroException 物件 28 double quotient( int numerator, int denominator ) 29 { 30 // 假如除數為 0 丟出 DivideByZeroException 例外並結束此函式 31 if ( denominator == 0 ) 32 throw DivideByZeroException(); // 丟出例外並結束函式執行 // 傳回除法運算結果 35 return static_cast< double >( numerator ) / denominator; } // end function quotient int main() 40 { 41 int number1; // 使用者指定的被除數 42 int number2; // 使用者指定的除數 43 double result; // 除法運算結果 cout << "Enter two integers (end-of-file to end): "; 46 Outline fig13_01.cpp (2 of 3) Prentice Hall, Inc. All rights reserved.

13 47 // 要求使用者輸入被除數與除數 48 while ( cin >> number1 >> number2 ) { // try 區塊內含可能傳回例外的程式碼 51 // 以及當例外發生時不應執行的程式碼 52 try { 53 result = quotient( number1, number2 ); 54 cout << "The quotient is: " << result << endl; } // end try // 例外處理程式 : 處理除 0 例外 59 catch ( DivideByZeroException &dividebyzeroexception ) { 60 cout << "Exception occurred: " 61 << dividebyzeroexception.what() << endl; } // end catch cout << "\nenter two integers (end-of-file to end): "; } // end while cout << endl; return 0; // 正常結束 } // end main Outline fig13_01.cpp (3 of 3) 2003 Prentice Hall, Inc. All rights reserved. 13

14 Enter two integers (end-of-file to end): The quotient is: Enter two integers (end-of-file to end): Exception occurred: attempted to divide by zero Enter two integers (end-of-file to end): ^Z Outline fig13_01.cpp output (1 of 1) Prentice Hall, Inc. All rights reserved.

15 重新丟出例外 重新丟出例外 當例外處理程式不能完全處理例外時 處理一部份, 再重新丟出 上層的 try 區塊與相對應的 catch 區塊會處理 要重新丟出例外 使用指令 "throw;" 不需參數 結束函式執行

16 1 // Fig. 13.2: fig13_02.cpp 2 // 重新丟出例外範例程式 3 #include <iostream> 4 5 using std::cout; 6 using std::endl; 7 8 #include <exception> 9 10 using std::exception; // throw, catch and rethrow exception 13 void throwexception() 14 { 15 // 丟出例外並利用 catch 捉住例外 16 try { 17 cout << " Function throwexception throws an exception\n"; 18 throw exception(); // 產生例外 } // end try // 處理例外 23 catch ( exception &caughtexception ) { 24 cout << " Exception handled in function throwexception" 25 << "\n Function throwexception rethrows exception"; throw; // 重新丟出例外 } // end catch Outline fig13_02.cpp (1 of 2) 2003 Prentice Hall, Inc. All rights reserved. 16

17 30 31 cout << "This also should not print\n"; } // end function throwexception int main() 36 { 37 // 丟出例外 38 try { 39 cout << "\nmain invokes function throwexception\n"; 40 throwexception(); 41 cout << "This should not print\n"; } // end try // 處理例外 46 catch ( exception &caughtexception ) { 47 cout << "\n\nexception handled in main\n"; } // end catch cout << "Program control continues after catch in main\n"; return 0; } // end main Outline fig13_02.cpp (2 of 2) 2003 Prentice Hall, Inc. All rights reserved. 17

18 main invokes function throwexception Function throwexception throws an exception Exception handled in function throwexception Function throwexception rethrows exception Exception handled in main Program control continues after catch in main Outline fig13_02.cpp output (1 of 1) Prentice Hall, Inc. All rights reserved.

19 函式例外清單 列出函式可能丟出的例外 例外丟出清單 int somefunction( double value ) throw ( ExceptionA, ExceptionB, ExceptionC ) { // function body } 函式只能丟出例外 ExceptionA, ExceptionB, ExceptionC 或以上例外的衍生類別 如果丟出其它例外, 會呼叫 unexpected 函式

20 函式例外清單 沒有例外丟出清單 可丟出任何種類例外 例外丟出清單沒列任何例外 不能丟出例外

21 處理非預期 (unexpected) 例外 unexpected 函式 利用 set_unexpected 函式 <exception> 預設值會終止程式執行 set_terminate 設定處理函式 函式沒有輸入 傳回值為 void 預設函式 :abort 如果有設定處理函式, 處理函式執行完也會呼叫 abort

22 堆疊返回 如果例外被丟出但是沒有被捉住 結束目前函式 清除函式呼叫堆疊 搜尋可處理例外的 try/catch 如果沒有找到則再回到上一層 假如例外都沒被捉住 結束程式執行

23 1 // Fig. 13.3: fig13_03.cpp 2 // 堆疊重返說明範例程式. 3 #include <iostream> 4 5 using std::cout; 6 using std::endl; 7 8 #include <stdexcept> // 使用 runtime_error 例外 9 10 using std::runtime_error; // function3 丟出 runtime_error 例外 13 void function3() throw ( runtime_error ) 14 { 15 throw runtime_error( runtime_error in function3 ); // 4 16 } // function2 呼叫 function3 19 void function2() throw ( runtime_error ) 20 { 21 function3(); // 3 22 } 23 Outline fig13_03.cpp (1 of 2) Prentice Hall, Inc. All rights reserved.

24 24 // function1 呼叫 function2 25 void function1() throw ( runtime_error ) 26 { 27 function2(); // 2 28 } // 主程式 31 int main() 32 { 33 // 呼叫 function1 34 try { 35 function1(); // } // end try // 處理 runtime_error 40 catch ( runtime_error &error ) // 5 41 { 42 cout << "Exception occurred: " << error.what() << endl; } // end catch return 0; } // end main Outline fig13_03.cpp (2 of 2) 24 Exception occurred: runtime_error in function Prentice Hall, Inc. All rights reserved.

25 建構子, 解構子, 與例外處理 建構子內的錯誤 new 失敗 ; 不能配置記憶體 程式直接終止, 無法呼叫解構子 解決方法 : Increment::Increment( int c, int i ) { try { ary1=new int[c]; ary2=new int[c]; } catch(...) { delete this; throw; } } // end constructor Increment

26 建構子, 解構子, 與例外處理 成員函式的錯誤 物件型態 MyClass myclass(...); 物件結束前會自動呼叫解構子 物件指標 MyClass *myclassptr=new MyClass(...); 例外情況可能無法 delete 物件 可將物件指標宣稱成自動指標 auto_ptr

27 例外與繼承 例外類別 可繼承基礎例外類別 I.e., exception 用 catch 捕捉基礎類別也能捕捉衍生類別 多型程式設計

28 處理 new 失敗情形 當 new 失敗時 丟出 bad_alloc 例外 定義在 <new> 某些編譯器會讓 new 傳回 0 結果跟編譯器有關

29 1 // Fig. 13.4: fig13_04.cpp 2 // 範例程式 3 // 說明 new 發生錯誤時會傳回 0 4 #include <iostream> 5 6 using std::cout; 7 8 int main() 9 { 10 double *ptr[ 50 ]; // 配置記憶體給 ptr 13 for ( int i = 0; i < 50; i++ ) { 14 ptr[ i ] = new double[ ]; // 配置記憶體失敗 new 會傳回 0 17 if ( ptr[ i ] == 0 ) { 18 cout << "Memory allocation failed for ptr[ " 19 << i << " ]\n"; break; } // end if 24 Outline fig13_04.cpp (1 of 2) 2003 Prentice Hall, Inc. All rights reserved. 29

30 25 // 成功配置記憶體 26 else 27 cout << "Allocated doubles in ptr[ " 28 << i << " ]\n"; } // end for return 0; } // end main Outline fig13_04.cpp (2 of 2) fig13_04.cpp output (1 of 1) 30 Allocated doubles in ptr[ 0 ] Allocated doubles in ptr[ 1 ] Allocated doubles in ptr[ 2 ] Allocated doubles in ptr[ 3 ] Memory allocation failed for ptr[ 4 ] 2003 Prentice Hall, Inc. All rights reserved.

31 1 // Fig. 13.5: fig13_05.cpp 2 // 範例程式 - 使用標準 new 函式 3 // 說明 new 失敗會丟出 bad_alloc 例外 4 #include <iostream> 5 6 using std::cout; 7 using std::endl; 8 9 #include <new> // 引用 new 標頭檔 using std::bad_alloc; // 使用 bad_alloc 例外 int main() 14 { 15 double *ptr[ 50 ]; // 嘗試配置記憶體 18 try { // 配置記憶體給 ptr[ i ]; new throws bad_alloc 21 // 失敗 :new 會丟出 bad_alloc 例外 22 for ( int i = 0; i < 50; i++ ) { 23 ptr[ i ] = new double[ ]; 24 cout << "Allocated doubles in ptr[ " 25 << i << " ]\n"; 26 } } // end try Outline fig13_05.cpp (1 of 2) 2003 Prentice Hall, Inc. All rights reserved. 31

32 29 30 // 處理 bad_alloc 例外 31 catch ( bad_alloc &memoryallocationexception ) { 32 cout << "Exception occurred: " 33 << memoryallocationexception.what() << endl; } // end catch return 0; } // end main Outline fig13_05.cpp (2 of 2) fig13_05.cpp output (1 of 1) 32 Allocated doubles in ptr[ 0 ] Allocated doubles in ptr[ 1 ] Allocated doubles in ptr[ 2 ] Allocated doubles in ptr[ 3 ] Exception occurred: Allocation Failure 2003 Prentice Hall, Inc. All rights reserved.

33 處理 new 失敗情形 set_new_handler 標頭檔 <new> 設定一個函式處理 new 的錯誤 沒有輸入參數 傳回值 :void 輸入參數 : 函式指標 設定完, new 失敗會呼叫此函式, 不丟出例外 範例程式

34 1 // Fig. 13.6: fig13_06.cpp 2 // set_new_handler 使用範例 3 #include <iostream> 4 5 using std::cout; 6 using std::cerr; 7 8 #include <new> // 引用 new 9 10 using std::set_new_handler; #include <cstdlib> // 引用 abort 函式原型 void customnewhandler() 15 { 16 cerr << "customnewhandler was called"; 17 abort(); 18 } // 使用 set_new_handler 處理記憶體配置失敗 21 int main() 22 { 23 double *ptr[ 50 ]; 24 Outline fig13_06.cpp (1 of 2) 2003 Prentice Hall, Inc. All rights reserved. 34

35 25 // 指定 customnewhandler 函式, 26 // 處理記憶體配置失敗 27 set_new_handler( customnewhandler ); // 配置記憶體給 ptr[ i ] 30 // 記憶體配置失敗時 customnewhandler 會被呼叫 31 for ( int i = 0; i < 50; i++ ) { 32 ptr[ i ] = new double[ ]; cout << "Allocated doubles in ptr[ " 35 << i << " ]\n"; } // end for return 0; } // end main Outline fig13_06.cpp (2 of 2) fig13_06.cpp output (1 of 1) 35 Allocated doubles in ptr[ 0 ] Allocated doubles in ptr[ 1 ] Allocated doubles in ptr[ 2 ] Allocated doubles in ptr[ 3 ] customnewhandler was called 2003 Prentice Hall, Inc. All rights reserved.

36 auto_ptr 類別與動態記憶體配置 宣稱指標, 使用 new 配置記憶體 例外發生在 delete 之前會導致 - Memory leak 類別樣版 auto_ptr 標頭檔 <memory> 當指標超出範圍, 自動呼叫 delete 用法 auto_ptr< MyClass > newpointer( new MyClass() ); newpointer 會指到動態配置的物件

37 1 // Fig. 13.7: fig13_07.cpp 2 // auto_ptr 使用範例 3 #include <iostream> 4 5 using std::cout; 6 using std::endl; 7 8 #include <memory> // 使用 auto_ptr 9 10 using std::auto_ptr; // 使用 auto_ptr 類別定義 class Integer { public: // 建構子 17 Integer( int i = 0 ) 18 : value( i ) 19 { 20 cout << "Constructor for Integer " << value << endl; } // end Integer constructor 23 Outline fig13_07.cpp (1 of 3) Prentice Hall, Inc. All rights reserved.

38 24 // 解構子 25 ~Integer() 26 { 27 cout << "Destructor for Integer " << value << endl; } // end Integer destructor // 設定 value 的值 32 void setinteger( int i ) 33 { 34 value = i; } // end function setinteger // 傳回 value 的值 39 int getinteger() const 40 { 41 return value; } // end function getinteger private: 46 int value; }; // end class Integer 49 Outline fig13_07.cpp (2 of 3) 2003 Prentice Hall, Inc. All rights reserved. 38

39 50 // 使用 auto_ptr 操作 Integer 物件 51 int main() 52 { 53 cout << "Creating an auto_ptr object that points to an " 54 << "Integer\n"; // 令 auto_ptr 指到 Integer 物件 57 auto_ptr< Integer > ptrtointeger( new Integer( 7 ) ); cout << "\nusing the auto_ptr to manipulate the Integer\n"; // 使用 auto_ptr 設定 Integer 的值 62 ptrtointeger->setinteger( 99 ); // 使用 auto_ptr 取得 Integer 的值 65 cout << "Integer after setinteger: " 66 << ( *ptrtointeger ).getinteger() 67 << "\n\nterminating program" << endl; return 0; } // end main Outline fig13_07.cpp (3 of 3) Prentice Hall, Inc. All rights reserved.

40 Creating an auto_ptr object that points to an Integer Constructor for Integer 7 Using the auto_ptr to manipulate the Integer Integer after setinteger: 99 Outline fig13_07.cpp output (1 of 1) 40 Terminating program Destructor for Integer Prentice Hall, Inc. All rights reserved.

Microsoft PowerPoint - 11_Templates.ppt

Microsoft PowerPoint - 11_Templates.ppt 1 1. 上機考 20% 期末考 6/23( 四 ) 晚 6:30~8:30 範圍 : 第 7, 8, 9, 10 章實習內容 按座位坐, 隨機抽兩題 2. 紙上測驗 20% 6/21( 二 ) :9:30~11:00 課本 7-11, 13 章內容 2 第 11 章樣版 (Templates) 11.1 簡介 11.2 函式樣版 11.3 多載函式樣版 11.4 類別樣版 11.5 類別樣版與無型

More information

新版 明解C++入門編

新版 明解C++入門編 511!... 43, 85!=... 42 "... 118 " "... 337 " "... 8, 290 #... 71 #... 413 #define... 128, 236, 413 #endif... 412 #ifndef... 412 #if... 412 #include... 6, 337 #undef... 413 %... 23, 27 %=... 97 &... 243,

More information

C++ 程式設計

C++ 程式設計 C C 料, 數, - 列 串 理 列 main 數串列 什 pointer) 數, 數, 數 數 省 不 不, 數 (1) 數, 不 數 * 料 * 數 int *int_ptr; char *ch_ptr; float *float_ptr; double *double_ptr; 數 (2) int i=3; int *ptr; ptr=&i; 1000 1012 ptr 數, 數 1004

More information

chp6.ppt

chp6.ppt Java 软 件 设 计 基 础 6. 异 常 处 理 编 程 时 会 遇 到 如 下 三 种 错 误 : 语 法 错 误 (syntax error) 没 有 遵 循 语 言 的 规 则, 出 现 语 法 格 式 上 的 错 误, 可 被 编 译 器 发 现 并 易 于 纠 正 ; 逻 辑 错 误 (logic error) 即 我 们 常 说 的 bug, 意 指 编 写 的 代 码 在 执 行

More information

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf ("%d", & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf (%d, & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9 201 201 21 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 1 B 1 C 5 D RPG 10 E 10 F 1 G II 1 1 201 201 C 1 # include 2 int main ( void

More information

c_cpp

c_cpp C C++ C C++ C++ (object oriented) C C++.cpp C C++ C C++ : for (int i=0;i

More information

untitled

untitled (encapsulation) 例 類 說 類 料 來 料 information hiding 念 (inheritance) 來說 類 類 類 類 類 類 行 利 來 (polymorphism) 不 類 數 不 1 2 3 4 類 類 不 類 不 類 5 6 7 // virtual 不見了 #include #include using namespace

More information

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf ("%d", & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf ("%d %d

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf (%d, & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf (%d %d 2013 18 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp, Compilation Error cin scanf Time Limit Exceeded 1: A 5 B 5 C 5 D 5 E 5 F 5 1 2013 C 1 # include 2 int main ( void ) 3 { 4 int cases, a, b,

More information

1: public class MyOutputStream implements AutoCloseable { 3: public void close() throws IOException { 4: throw new IOException(); 5: } 6:

1: public class MyOutputStream implements AutoCloseable { 3: public void close() throws IOException { 4: throw new IOException(); 5: } 6: Chapter 15. Suppressed Exception CH14 Finally Block Java SE 7 try-with-resources JVM cleanup try-with-resources JVM cleanup cleanup Java SE 7 Throwable getsuppressed Throwable[] getsuppressed() Suppressed

More information

ebook39-5

ebook39-5 5 3 last-in-first-out, LIFO 3-1 L i n e a r L i s t 3-8 C h a i n 3 3. 8. 3 C + + 5.1 [ ] s t a c k t o p b o t t o m 5-1a 5-1a E D 5-1b 5-1b E E 5-1a 5-1b 5-1c E t o p D t o p D C C B B B t o p A b o

More information

投影片 1

投影片 1 資料庫管理程式 ( 補充教材 -Part2) 使用 ADO.NET 連結資料庫 ( 自行撰寫程式碼 以實現新增 刪除 修改等功能 ) Private Sub InsertButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InsertButton.Click ' 宣告相關的 Connection

More information

第二章 簡介類別

第二章  簡介類別 Instructor Hsueh-Wen Tseng 曾學文,hwtseng@nchu.edu.tw Textbook C++ 程式設計風格與藝術 (O Reilly). Requirements Assignment x? 100% TAs 第一章概觀 C++ 1-2 二種版本的 C++ 1-5 初步檢視類別 1-1 何謂物件導向程式設計 1-8 C++ 的關鍵字 1-2 二種版本的 C++ //

More information

Microsoft Word - 01.DOC

Microsoft Word - 01.DOC 第 1 章 JavaScript 简 介 JavaScript 是 NetScape 公 司 为 Navigator 浏 览 器 开 发 的, 是 写 在 HTML 文 件 中 的 一 种 脚 本 语 言, 能 实 现 网 页 内 容 的 交 互 显 示 当 用 户 在 客 户 端 显 示 该 网 页 时, 浏 览 器 就 会 执 行 JavaScript 程 序, 用 户 通 过 交 互 式 的

More information

Microsoft PowerPoint - ch15.ppt

Microsoft PowerPoint - ch15.ppt Exception Handling Exception handling Exception Indication of problem during execution E.g., divide by zero Chained exceptions 1 Exception-Handling Overview Uses of exception handling Process exceptions

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

ebook39-6

ebook39-6 6 first-in-first-out, FIFO L i n e a r L i s t 3-1 C h a i n 3-8 5. 5. 3 F I F O L I F O 5. 5. 6 5. 5. 6.1 [ ] q u e n e ( r e a r ) ( f r o n t 6-1a A 6-1b 6-1b D C D 6-1c a) b) c) 6-1 F I F O L I F ADT

More information

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf("%d", &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf("%

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf(%d, &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf(% 2013 ( 28 ) ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 10 B 1 C 1 D 5 E 5 F 1 G II 5 H 30 1 2013 C 1 #include 2 int main(void) 3

More information

untitled

untitled 1 Outline ArrayList 類 列類 串類 類 類 例 理 MSDN Library MSDN Library 量 例 參 列 [ 說 ] [] [ 索 ] [] 來 MSDN Library 了 類 類 利 F1 http://msdn.microsoft.com/library/ http://msdn.microsoft.com/library/cht/ Object object

More information

Microsoft PowerPoint - Class5.pptx

Microsoft PowerPoint - Class5.pptx C++ 程式初探 V 2015 暑期 ver. 1.0.1 C++ 程式語言 大綱 1. 大量檔案讀取 & 計算 2. 指標 3. 動態記憶體 & 動態陣列 4. 標準函式庫 (STL) vector, algorithm 5. 結構與類別 2 大量檔案讀取 & 計算 若目前有一個程式將讀取純文字文件 (.txt) 中的整數, 並將該文件中的整數有小到大排序後, 儲存到另外一個新的純文字件中 假設有

More information

全国计算机技术与软件专业技术资格(水平)考试

全国计算机技术与软件专业技术资格(水平)考试 全 国 计 算 机 技 术 与 软 件 专 业 技 术 资 格 ( 水 平 ) 考 试 2008 年 上 半 年 程 序 员 下 午 试 卷 ( 考 试 时 间 14:00~16:30 共 150 分 钟 ) 试 题 一 ( 共 15 分 ) 阅 读 以 下 说 明 和 流 程 图, 填 补 流 程 图 中 的 空 缺 (1)~(9), 将 解 答 填 入 答 题 纸 的 对 应 栏 内 [ 说 明

More information

3. 企 业 债 券 : 公 司 债 券 : 5. 证 券 公 司 债 券 : 6. 企 业 短 期 融 资 券 : 7. 中 期 票 据 : 8. 资 产 支 持 证 券 : 9. 国 际 开 发 机 构 人 民 币 债 券 : 10. 中 小 非 金 融 企 业 集 合 票 据 例 题? 判 断

3. 企 业 债 券 : 公 司 债 券 : 5. 证 券 公 司 债 券 : 6. 企 业 短 期 融 资 券 : 7. 中 期 票 据 : 8. 资 产 支 持 证 券 : 9. 国 际 开 发 机 构 人 民 币 债 券 : 10. 中 小 非 金 融 企 业 集 合 票 据 例 题? 判 断 第 1 节 投 资 银 行 业 务 概 述 1. 投 资 银 行 的 含 义 [ 熟 悉 ]: 等 第 1 章 证 劵 经 营 机 构 的 投 资 银 行 业 务 (1) 狭 义 的 就 是 指 某 些 资 本 市 场 活 动, 着 重 指 一 级 市 场 上 的 承 销 并 购 和 融 资 活 动 的 财 务 顾 问 (2) 广 义 的 包 括 公 司 融 资 并 购 顾 问 股 票 和 债 券

More information

運算子多載 Operator Overloading

運算子多載 Operator Overloading 多型 Polymorphism 講師 : 洪安 1 多型 編譯時期多型 ( 靜態多型 ) function overloading 如何正確呼叫同名的函數? 利用參數個數與型態 operator overloading 其實同 function overloading 執行時期多型 ( 或動態多型 ) 如何正確呼叫不同物件的相同名稱的成員函數 利用繼承與多型 2 子類別與父類別物件間的指定 (assignment)

More information

優質居所 攜手共建

優質居所 攜手共建 2000 Housing Authority. All rights reserved. 2000 Housing Authority. All rights reserved. 2000 Housing Authority. All rights reserved. 2000 Housing Authority. All rights reserved. 2000 Housing Authority.

More information

《大话设计模式》第一章

《大话设计模式》第一章 第 1 章 代 码 无 错 就 是 优? 简 单 工 厂 模 式 1.1 面 试 受 挫 小 菜 今 年 计 算 机 专 业 大 四 了, 学 了 不 少 软 件 开 发 方 面 的 东 西, 也 学 着 编 了 些 小 程 序, 踌 躇 满 志, 一 心 要 找 一 个 好 单 位 当 投 递 了 无 数 份 简 历 后, 终 于 收 到 了 一 个 单 位 的 面 试 通 知, 小 菜 欣 喜

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

untitled

untitled 1 Outline 料 類 說 Tang, Shih-Hsuan 2006/07/26 ~ 2006/09/02 六 PM 7:00 ~ 9:30 聯 ives.net@gmail.com www.csie.ntu.edu.tw/~r93057/aspnet134 度 C# 力 度 C# Web SQL 料 DataGrid DataList 參 ASP.NET 1.0 C# 例 ASP.NET 立

More information

C/C++语言 - C/C++数据

C/C++语言 - C/C++数据 C/C++ C/C++ Table of contents 1. 2. 3. 4. char 5. 1 C = 5 (F 32). 9 F C 2 1 // fal2cel. c: Convert Fah temperature to Cel temperature 2 # include < stdio.h> 3 int main ( void ) 4 { 5 float fah, cel ;

More information

Microsoft PowerPoint - EmbSys101_Java Basics.ppt [相容模式]

Microsoft PowerPoint - EmbSys101_Java Basics.ppt [相容模式] Java Basics Hi Hsiao-Lung Chan, Ph.D. Dept Electrical Engineering Chang Gung University, Taiwan chanhl@maili.cgu.edu.twcgu 執行環境 - eclipse 點選 eclipse 軟體執行檔 設定工作路徑 eclipse 開啟 2 建置 Java 專案 File New project

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 9 [P.11] : Dev C++ [P.12] : http://c.feis.tw [P.13] [P.14] [P.15] [P.17] [P.23] Dev C++ [P.24] [P.27] [P.34] C / C++ [P.35] 10 C / C++ C C++ C C++ C++ C ( ) C++

More information

第3章.doc

第3章.doc 3 3 3 3.1 3 IT Trend C++ Java SAP Advantech ERPCRM C++ C++ Synopsys C++ NEC C C++PHP C++Java C++Java VIA C++ 3COM C++ SPSS C++ Sybase C++LinuxUNIX Motorola C++ IBM C++Java Oracle Java HP C++ C++ Yahoo

More information

運算子多載 Operator Overloading

運算子多載 Operator Overloading 函數樣板 (Function Template) 與 類別樣板 (Class Template) 講師 : 洪安 1 資料結構與 C++ 程式設計進階班 為何需要通用函數? (1/2) int abs(int x) { return (x>0)?x:-x; 取名困難不好記 float fabs(float x) { return (x>0)?x:-x; complex cabs(complex x)

More information

第七讲 继承与多态

第七讲  继承与多态 第 七 章 继 承 与 派 生 1 本 章 主 要 内 容 的 继 承 成 员 的 访 问 控 制 单 继 承 与 多 继 承 派 生 的 构 造 析 构 函 数 成 员 的 标 识 与 访 问 深 度 探 索 2 的 继 承 与 派 生 的 继 承 与 派 生 保 持 已 有 的 特 性 而 构 造 新 的 过 程 称 为 继 承 在 已 有 的 基 础 上 新 增 自 己 的 特 性 而 产 生

More information

踏出C++的第一步

踏出C++的第一步 踏出 C++ 的第一步 講師 : 洪安 1 已經學會的 C 語言基本概念 基本資料型態 變數 基本輸入輸出 控制敘述 選擇控制 迴圈 陣列 函式 指標 字元與字串 結構 檔案處理 2 C v.s. C++ C 函數 程序式語言 Procedural language 結構化程式設計 Structured programming 演算法 Top-down C++ 類別 物件導向程式設計 Object-Oriented

More information

untitled

untitled 1 MSDN Library MSDN Library 量 例 參 列 [ 說 ] [] [ 索 ] [] 來 MSDN Library 了 類 類 利 F1 http://msdn.microsoft.com/library/ http://msdn.microsoft.com/library/cht/ Object object 參 類 都 object 參 object Boxing 參 boxing

More information

Microsoft Word - 970617cppFinalSolution.doc

Microsoft Word - 970617cppFinalSolution.doc 國 立 台 灣 海 洋 大 學 資 訊 工 程 系 C++ 程 式 設 計 期 末 考 參 考 答 案 姓 名 : 系 級 : 學 號 : 97/06/17 考 試 時 間 :10:00 12:10 試 題 敘 述 蠻 多 的, 看 清 楚 題 目 問 什 麼, 針 對 重 點 回 答 是 很 重 要 的 ; 不 確 定 的 請 一 定 要 當 場 提 出 來, 不 要 白 花 力 氣 在 誤 會

More information

chap07.key

chap07.key #include void two(); void three(); int main() printf("i'm in main.\n"); two(); return 0; void two() printf("i'm in two.\n"); three(); void three() printf("i'm in three.\n"); void, int 标识符逗号分隔,

More information

Strings

Strings Inheritance Cheng-Chin Chiang Relationships among Classes A 類 別 使 用 B 類 別 學 生 使 用 手 機 傳 遞 訊 息 公 司 使 用 金 庫 儲 存 重 要 文 件 人 類 使 用 交 通 工 具 旅 行 A 類 別 中 有 B 類 別 汽 車 有 輪 子 三 角 形 有 三 個 頂 點 電 腦 內 有 中 央 處 理 單 元 A

More information

Microsoft Word - PHP7Ch01.docx

Microsoft Word - PHP7Ch01.docx PHP 01 1-6 PHP PHP HTML HTML PHP CSSJavaScript PHP PHP 1-6-1 PHP HTML PHP HTML 1. Notepad++ \ch01\hello.php 01: 02: 03: 04: 05: PHP 06:

More information

3.1 num = 3 ch = 'C' 2

3.1 num = 3 ch = 'C' 2 Java 1 3.1 num = 3 ch = 'C' 2 final 3.1 final : final final double PI=3.1415926; 3 3.2 4 int 3.2 (long int) (int) (short int) (byte) short sum; // sum 5 3.2 Java int long num=32967359818l; C:\java\app3_2.java:6:

More information

任務二 : 產生 20 個有炸彈的磚塊, 放在隨機的位置編輯 Block 類別的程式碼 import greenfoot.; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) Write a description of class

任務二 : 產生 20 個有炸彈的磚塊, 放在隨機的位置編輯 Block 類別的程式碼 import greenfoot.; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) Write a description of class 踩地雷遊戲 高慧君南港高中 開啟專案 MineSweep 任務一 : 產生 30X20 個磚塊編輯 Table 類別的程式碼 import greenfoot.; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.util.arraylist; Write a description of class MyWorld

More information

單步除錯 (1/10) 打開 Android Studio, 點選 Start a new Android Studio project 建立專案 Application name 輸入 BMI 點下 Next 2 P a g e

單步除錯 (1/10) 打開 Android Studio, 點選 Start a new Android Studio project 建立專案 Application name 輸入 BMI 點下 Next 2 P a g e Android Studio Debugging 本篇教學除了最基本的中斷點教學之外, 還有條件式中斷的教學 條件式中斷是進階的除錯技巧, 在某些特定情況中, 我們有一個函數可能會被呼叫數次, 但是我們只希望在某種條件成立時才進行中斷, 進而觀察變數的狀態 而條件式中斷這項技巧正是符合這項需求 本教學分兩部分 單步除錯 (Page2~11, 共 10) 條件式中斷點 (Page12~17, 共 6)

More information

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 Java V1.0.1 2007 4 10 1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 6.2.10 6.3..10 6.4 11 7.12 7.1

More information

Microsoft PowerPoint - 09_Inheritance.ppt

Microsoft PowerPoint - 09_Inheritance.ppt 1 第九章 - 繼承 (Inheritance) 9.1 簡介 9.2 基本類別與衍生類別 9.3 受保護的成員 9.4 基本類別與衍生類別的關係 9.5 案例研究 : 三層繼承架構 9.6 衍生類別的建構子與解構子 9.8 public, protected, 與 private 繼承關係 9.9 繼承的優點 2 9.1 簡介 不同類別之間的關係 合成關係與繼承關係 合成關係 ( has-a )

More information

untitled

untitled 3 C++ 3.1 3.2 3.3 3.4 new delete 3.5 this 3.6 3.7 3.1 3.1 class struct union struct union C class C++ C++ 3.1 3.1 #include struct STRING { typedef char *CHARPTR; // CHARPTR s; // int strlen(

More information

¬¬

¬¬ 2 年 第 9 周 2.2.2-2.2.27 26 年 第 7 周 : 受 春 节 影 响, 一 二 级 市 场 无 供 应 成 交 26 年 第 7 周 (26 年 2 月 8 日 26 年 2 月 4 日 ) 哈 尔 滨 市 无 土 地 供 应 26 年 第 7 周 (26 年 2 月 8 日 26 年 2 月 4 日 ) 哈 尔 滨 市 无 土 地 成 交 26 年 第 7 周 (26 年 2

More information

2 WF 1 T I P WF WF WF WF WF WF WF WF 2.1 WF WF WF WF WF WF

2 WF 1 T I P WF WF WF WF WF WF WF WF 2.1 WF WF WF WF WF WF Chapter 2 WF 2.1 WF 2.2 2. XAML 2. 2 WF 1 T I P WF WF WF WF WF WF WF WF 2.1 WF WF WF WF WF WF WF WF WF WF EDI API WF Visual Studio Designer 1 2.1 WF Windows Workflow Foundation 2 WF 1 WF Domain-Specific

More information

Strings

Strings Polymorphism and Virtual Functions Cheng-Chin Chiang Virtual Function Basics 多 型 (Polymorphism) 賦 予 一 個 函 數 多 種 意 涵, 存 在 於 同 一 類 別 之 內 祖 先 類 別 與 後 代 類 別 間 物 件 導 向 程 式 設 計 基 本 原 理 虛 擬 函 數 (Virtual Function)

More information

untitled

untitled 4.1AOP AOP Aspect-oriented programming AOP 來說 AOP 令 理 Cross-cutting concerns Aspect Weave 理 Spring AOP 來 AOP 念 4.1.1 理 AOP AOP 見 例 來 例 錄 Logging 錄 便 來 例 行 留 錄 import java.util.logging.*; public class HelloSpeaker

More information

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2 Chapter 02 變數與運算式 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.2 2.2.1 2.2.2 2.2.3 type 2.2.4 2.3 2.3.1 print 2.3.2 input 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 + 2.4.6 Python Python 2.1 2.1.1 a p p l e b e a r c 65438790

More information

All Rights Reserved, National Library Board, Singapore All Rights Reserved, National Library Board, Singapore All Rights Reserved, National Library Board, Singapore All Rights Reserved, National Library

More information

All Rights Reserved, National Library Board, Singapore All Rights Reserved, National Library Board, Singapore All Rights Reserved, National Library Board, Singapore All Rights Reserved, National

More information

All Rights Reserved, National Library Board, Singapore All Rights Reserved, National Library Board, Singapore All Rights Reserved, National Library Board, Singapore All Rights Reserved, National Library

More information

The golden pins of the PCI card can be oxidized after months or years

The golden pins of the PCI card can be oxidized after months or years Q. 如何在 LabWindows/CVI 編譯 DAQ Card 程式? A: 請參考至下列步驟 : 步驟 1: 安裝驅動程式 1. 安裝 UniDAQ 驅動程式 UniDAQ 驅動程式下載位置 : CD:\NAPDOS\PCI\UniDAQ\DLL\Driver\ ftp://ftp.icpdas.com/pub/cd/iocard/pci/napdos/pci/unidaq/dll/driver/

More information

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc References (Section 5.2) Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 15-16, 2010 H.-T. Lin (NTU CSIE) References OOP 03/15-16/2010 0 / 22 Fun Time (1) What happens in memory? 1 i n t i ; 2

More information

Microsoft PowerPoint - ch11.ppt

Microsoft PowerPoint - ch11.ppt 11 前處理指令 前處理指令可以要求前處理器 (preprocessor) 在程式編譯之前, 先進行加入其它檔案的內容 文字取代以及選擇性編譯等工作 1/39 前處理指令 11.1 11.2 11.3 11.4 11.5 前處理器使用 #define 進行文字取代使用 #define 設定巨集指令條件式編譯其他與編譯器有關的前處理指令 2/39 3/39 前處理指令 #include 前處理指令不是

More information

Microsoft PowerPoint - 13_ClassAndObj.ppt

Microsoft PowerPoint - 13_ClassAndObj.ppt Visual Basic 2005 (VB.net 2.0) 程式設計 講師 : 戴志華 hana@arbor.ee.ntu.edu.tw 國立台灣大學電機工程研究所 第十三章 物件與類別 物件與類別 物件導向程式設計 物件與類別的建立 物件與類別 物件 (object) Ex. 人 屬性 (property) 身高 體重 血型 方法 (method) 走路 跑步 訊息 (message) 交談 事件

More information

C/C++ 语言 - 循环

C/C++ 语言 - 循环 C/C++ Table of contents 7. 1. 2. while 3. 4. 5. for 6. 8. (do while) 9. 10. (nested loop) 11. 12. 13. 1 // summing.c: # include int main ( void ) { long num ; long sum = 0L; int status ; printf

More information

Microsoft Word - ch04三校.doc

Microsoft Word - ch04三校.doc 4-1 4-1-1 (Object) (State) (Behavior) ( ) ( ) ( method) ( properties) ( functions) 4-2 4-1-2 (Message) ( ) ( ) ( ) A B A ( ) ( ) ( YourCar) ( changegear) ( lowergear) 4-1-3 (Class) (Blueprint) 4-3 changegear

More information

内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2

内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2 第 六 讲 指 针 与 字 符 串 1 内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2 指 针 什 么 是 指 针 指 针 的 定 义 与 运 算 指 针 与 一 维 数 组 指 针 数 组 行 指 针 与 二 维 数 组 指 针 与 引 用 指 针 与 函 数 3 指 针 定 义 什 么 是 指 针 指 针 变 量, 简 称 指 针, 用 来 存 放

More information

untitled

untitled 1 行 行 行 行.NET 行 行 類 來 行 行 Thread 類 行 System.Threading 來 類 Thread 類 (1) public Thread(ThreadStart start ); Name 行 IsAlive 行 行狀 Start 行 行 Suspend 行 Resume 行 行 Thread 類 (2) Sleep 行 CurrentThread 行 ThreadStart

More information

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp 01 1.6 Spyder Anaconda Spyder Python Spyder Python Spyder Spyder 1.6.1 Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Spyder Python File

More information

Chapter 8 - Operator Overloading

Chapter 8 - Operator Overloading 1 第八章 - 運算子多載 Operator Overloading 8.1 簡介 8.2 運算子多載基本原理 8.3 運算子多載的限制 8.4 運算子函式 - 成員函式與非成員函式 8.5 多載 > 運算子 8.6 多載單運算元運算子 (Unary Operators) 8.7 多載雙運算元運算子 (Binary Operators) 8.8 案例研讀 : Array 類別 8.9 物件型別轉換

More information

2002 Shintoukai Chinese Academy. All rights reserved 2

2002 Shintoukai Chinese Academy. All rights reserved 2 2002 Shintoukai Chinese Academy. All rights reserved 1 2002 Shintoukai Chinese Academy. All rights reserved 2 2002 Shintoukai Chinese Academy. All rights reserved 3 2002 Shintoukai Chinese Academy. All

More information

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40 C C trio@seu.edu.cn C C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40 Week3 C Week5 Week5 Memory & Pointer

More information

文档 3

文档 3 1 2 3 4 5 6 / A B A B B A 7 8 9 10 11 12 OO A B A B 13 14 15 16 17 18 19 20 21 22 OOA OOA 23 24 25 OOA OOA 26 27 28 29 30 31 32 use case 33 use case 34 35 36 37 OOD OOA OOD 38 OOA 39 OOD 40 41 / 42 OOD

More information

試卷一

試卷一 香 香 港 港 考 中 試 及 學 評 文 核 憑 局 年 月 版 的 暫 定 稿 中 國 歷 史 試 卷 一 考 試 時 間 : 兩 小 時 ( 樣 本 試 卷 本 各 試 設 卷 共 題 分, 兩 考 部 生 分 須, 於 第 每 一 部 部 分 分 各 為 選 必 答 答 題, 各 每 考 題 生 佔 均 須 作 分 答, 佔 分 第 二 部 分 分 甲 乙 兩 部, 5 0 3 1 2 5

More information

untitled

untitled A, 3+A printf( ABCDEF ) 3+ printf( ABCDEF ) 2.1 C++ main main main) * ( ) ( ) [ ].* ->* ()[] [][] ** *& char (f)(int); ( ) (f) (f) f (int) f int char f char f(int) (f) char (*f)(int); (*f) (int) (

More information

Microsoft PowerPoint - L17_Inheritance_v4.pptx

Microsoft PowerPoint - L17_Inheritance_v4.pptx C++ Programming Lecture 17 Wei Liu ( 刘 威 ) Dept. of Electronics and Information Eng. Huazhong University of Science and Technology May. 2015 Lecture 17 Chapter 20. Object-Oriented Programming: Inheritance

More information

運算子多載 Operator Overloading

運算子多載 Operator Overloading 多載 Overloading 講師 : 洪安 1 多型 編譯時期多型 ( 靜態多型 ) function overloading 函數多載 如何正確呼叫同名的函數? 利用參數個數與型態 operator overloading 運算子多載 其實同 function overloading 執行時期多型 ( 或動態多型 ) 如何正確呼叫不同物件的相同名稱的成員函數 利用繼承與多型 2 函數多載 Function

More information

陳偉補習班環境介紹

陳偉補習班環境介紹 肆 各 专 业 科 目 可 报 考 学 校 一 览 表 选 考 : 经 济 学 ( 含 政 治 经 济 学 微 观 经 济 学 宏 观 经 济 学 ) 020201 国 民 经 济 学 8 北 京 光 华 管 理 学 020204 金 融 学 83 020205 产 业 经 济 学 4 清 华 经 济 管 理 学 020100 理 论 经 济 学 020200 应 用 经 济 学 6 020201

More information

Chapter12 Derived Classes

Chapter12   Derived Classes 继 承 -- 派 生 类 复 习 1. 有 下 面 类 的 说 明, 有 错 误 的 语 句 是 : class X { A) const int a; B) X(); C) X(int val) {a=2 D) ~X(); 答 案 :C 不 正 确, 应 改 成 X(int val) : a(2) { 2. 下 列 静 态 数 据 成 员 的 特 性 中, 错 误 的 是 A) 说 明 静 态 数

More information

EJB-Programming-4-cn.doc

EJB-Programming-4-cn.doc EJB (4) : (Entity Bean Value Object ) JBuilder EJB 2.x CMP EJB Relationships JBuilder EJB Test Client EJB EJB Seminar CMP Entity Beans Session Bean J2EE Session Façade Design Pattern Session Bean Session

More information

Microsoft Word - 11.doc

Microsoft Word - 11.doc 除 錯 技 巧 您 將 於 本 章 學 到 以 下 各 項 : 如 何 在 Visual C++ 2010 的 除 錯 工 具 控 制 下 執 行 程 式? 如 何 逐 步 地 執 行 程 式 的 敘 述? 如 何 監 看 或 改 變 程 式 中 的 變 數 值? 如 何 監 看 程 式 中 計 算 式 的 值? 何 謂 Call Stack? 何 謂 診 斷 器 (assertion)? 如 何

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 49 [P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : ,

More information

Microsoft PowerPoint - P766Ch06.ppt

Microsoft PowerPoint - P766Ch06.ppt PHP5&MySQL 程式設計 第 6 章物件導向 6-1 認識物件導向 物件 (object) 或 案例 (instance) 屬性 (property) 欄位 (field) 或 成員變數 (member variable) 方法 (method) 或 成員函式 (member function) 事件 (event) 類別 (class) 物件導向程式設計 (OOP) 具有下列特點 : 封裝

More information

2/80 2

2/80 2 2/80 2 3/80 3 DSP2400 is a high performance Digital Signal Processor (DSP) designed and developed by author s laboratory. It is designed for multimedia and wireless application. To develop application

More information

mvc

mvc Build an application Tutor : Michael Pan Application Source codes - - Frameworks Xib files - - Resources - ( ) info.plist - UIKit Framework UIApplication Event status bar, icon... delegation [UIApplication

More information

1994-2010 China Academic Journal Electronic Publishing House. All rights reserved. http://www.cnki.net 1994-2010 China Academic Journal Electronic Publishing House. All rights reserved. http://www.cnki.net

More information

Scott Effective C++ C++ C++ Roger Orr OR/2 ISO C++ Effective Modern C++ C++ C++ Scoot 42 Bart Vandewoestyne C++ C++ Scott Effective Modern C++ Damien

Scott Effective C++ C++ C++ Roger Orr OR/2 ISO C++ Effective Modern C++ C++ C++ Scoot 42 Bart Vandewoestyne C++ C++ Scott Effective Modern C++ Damien Effective Modern C++ C++ C++ C++11/C++14 C++ Scott Meyers Gerhard Kreuzer Siemens AG Effective Modern C++ Effective Modern C++ Andrei Alexandrescu Facebook Modern C++ Design C++ C++ Nevin Liber DRW Trading

More information

1994-2011 China Academic Journal Electronic Publishing House. All rights reserved.

1994-2011 China Academic Journal Electronic Publishing House. All rights reserved. 1994-2011 China Academic Journal Electronic Publishing House. All rights reserved. http://www.cnki.net 1994-2011 China Academic Journal Electronic Publishing House. All rights reserved. http://www.cnki.net

More information

China Academic Journal Electronic Publishing House. All rights reserved.

China Academic Journal Electronic Publishing House. All rights reserved. 1994-2010 China Academic Journal Electronic Publishing House. All rights reserved. http://www.cnki.net 1994-2010 China Academic Journal Electronic Publishing House. All rights reserved. http://www.cnki.net

More information

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 1994-2010 China Academic Journal Electronic Publishing House. All rights reserved. http://www.cnki.net ,,,,,, 1994-2010 China Academic Journal Electronic

More information

幻灯片 1

幻灯片 1 二 十 年 目 睹 之 怪 现 状 清 吴 沃 尧 (1866 1910) 著 吴 氏 原 字 茧 人 后 改 趼 人 广 东 南 海 人 因 居 佛 山 故 笔 名 我 佛 山 人 出 身 世 宦 之 家 因 家 道 中 落 20 多 岁 去 上 海 谋 生 后 客 居 山 东 又 远 游 日 本 1904 年 任 美 国 人 办 的 楚 报 主 笔 后 辞 职 返 沪 参 加 反 华 工 禁 约

More information

1994-2009 China Academic Journal Electronic Publishing House. All rights reserved. http://www.cnki.net 1994-2009 China Academic Journal Electronic Publishing House. All rights reserved. http://www.cnki.net

More information

目 录 欢 迎 使 用... 1 1. 产 品 介 绍... 2 1.1 产 品 概 述... 2 1.2 产 品 特 点... 2 2. 代 理 商 系 统 使 用 说 明... 3 2.1 登 陆... 3 2.2 基 本 信 息... 4 2.3 分 销 商 管 理... 5 2.4 帐 户

目 录 欢 迎 使 用... 1 1. 产 品 介 绍... 2 1.1 产 品 概 述... 2 1.2 产 品 特 点... 2 2. 代 理 商 系 统 使 用 说 明... 3 2.1 登 陆... 3 2.2 基 本 信 息... 4 2.3 分 销 商 管 理... 5 2.4 帐 户 悠 讯 (telyou) 代 理 商 手 册 (V1.0) 广 阔 网 络 通 信 技 术 有 限 公 司 1 目 录 欢 迎 使 用... 1 1. 产 品 介 绍... 2 1.1 产 品 概 述... 2 1.2 产 品 特 点... 2 2. 代 理 商 系 统 使 用 说 明... 3 2.1 登 陆... 3 2.2 基 本 信 息... 4 2.3 分 销 商 管 理... 5 2.4

More information

Chapter 9: Objects and Classes

Chapter 9: Objects and Classes Java application Java main applet Web applet Runnable Thread CPU Thread 1 Thread 2 Thread 3 CUP Thread 1 Thread 2 Thread 3 ,,. (new) Thread (runnable) start( ) CPU (running) run ( ) blocked CPU sleep(

More information

打 造 新 型 领 导 力 揭 示 未 来 领 导 力 面 临 的 新 挑 战 根 据 Hay ( 合 益 ) 集 团 2030 领 导 力 的 研 究 发 现, 未 来 的 领 导 者 想 要 成 功 就 必 须 掌 握 新 的 技 能 和 素 质 内 容 介 绍 2 1 全 球 范 围 内 的 力 量 对 比 正 在 发 生 变 化 5 2 气 候 变 化 和 资 源 匮 乏 的 问 题 与

More information

EJB-Programming-3.PDF

EJB-Programming-3.PDF :, JBuilder EJB 2.x CMP EJB Relationships JBuilder EJB Test Client EJB EJB Seminar CMP Entity Beans Value Object Design Pattern J2EE Design Patterns Value Object Value Object Factory J2EE EJB Test Client

More information

Microsoft Word - ACL0204-ch11-ok.doc

Microsoft Word - ACL0204-ch11-ok.doc 第十一章 類別和動態記憶體配置 這章主要討論如何在類別中使用 new 和 delete 及如何處理動態記憶體所產生的一些問題, 主題似乎很少, 但這些主題會影響建構函數及解構函數的設計以及運算子的多型 先看一個特別的例子 若要產生一個類別, 其成員表示姓名, 最簡單的方法是用字元陣列儲存 但其缺點是字元陣列的長度該設多少呢? 若為 14 個字元的陣列, 遇到 Barthlomew Smeadsbury-Crafthovingham

More information

Microsoft Word - 投影片ch13

Microsoft Word - 投影片ch13 Java2 JDK5.0 教學手冊第三版洪維恩編著博碩文化出版書號 pg20210 第十三章例外處理 本章學習目標了解什麼是例外處理認識例外類別的繼承架構認識例外處理的機制學習如何撰寫例外類別 例外處理 13-2 13.1 例外的基本觀念 在執行程式時, 經常發生一些不尋常的狀況 例如 : (1) 要開啟的檔案不存在 (2) 陣列的索引值超過了陣列容許的範圍 (3) 使用者輸入錯誤 Java 把這類不尋常的狀況稱為

More information

提问袁小兵:

提问袁小兵: C++ 面 试 试 题 汇 总 柯 贤 富 管 理 软 件 需 求 分 析 篇 1. STL 类 模 板 标 准 库 中 容 器 和 算 法 这 部 分 一 般 称 为 标 准 模 板 库 2. 为 什 么 定 义 虚 的 析 构 函 数? 避 免 内 存 问 题, 当 你 可 能 通 过 基 类 指 针 删 除 派 生 类 对 象 时 必 须 保 证 基 类 析 构 函 数 为 虚 函 数 3.

More information

Page 1 of 21 中 文 简 体 中 文 繁 体 邮 箱 搜 索 本 网 站 搜 索 搜 索 网 站 首 页 今 日 中 国 中 国 概 况 法 律 法 规 公 文 公 报 政 务 互 动 政 府 建 设 工 作 动 态 人 事 任 免 新 闻 发 布 当 前 位 置 : 首 页 >> 公 文 公 报 >> 国 务 院 文 件 >> 国 务 院 文 件 中 央 政 府 门 户 网 站 www.gov.cn

More information

untitled

untitled MODBUS 1 MODBUS...1 1...4 1.1...4 1.2...4 1.3...4 1.4... 2...5 2.1...5 2.2...5 3...6 3.1 OPENSERIAL...6 3.2 CLOSESERIAL...8 3.3 RDMULTIBIT...8 3.4 RDMULTIWORD...9 3.5 WRTONEBIT...11 3.6 WRTONEWORD...12

More information

(6) 要 求 付 款 管 理 员 从 预 订 表 中 查 询 距 预 订 的 会 议 时 间 两 周 内 的 预 定, 根 据 客 户 记 录 给 满 足 条 件 的 客 户 发 送 支 付 余 款 要 求 (7) 支 付 余 款 管 理 员 收 到 客 户 余 款 支 付 的 通 知 后, 检

(6) 要 求 付 款 管 理 员 从 预 订 表 中 查 询 距 预 订 的 会 议 时 间 两 周 内 的 预 定, 根 据 客 户 记 录 给 满 足 条 件 的 客 户 发 送 支 付 余 款 要 求 (7) 支 付 余 款 管 理 员 收 到 客 户 余 款 支 付 的 通 知 后, 检 2016 年 上 半 年 软 件 设 计 师 考 试 真 题 ( 下 午 题 ) 下 午 试 题 试 题 一 ( 共 15 分 ) 阅 读 下 列 说 明 和 图, 回 答 问 题 1 至 问 题 4, 将 解 答 填 入 答 题 纸 的 对 应 栏 内 说 明 某 会 议 中 心 提 供 举 办 会 议 的 场 地 设 施 和 各 种 设 备, 供 公 司 与 各 类 组 织 机 构 租 用 场

More information

目 录 第 一 部 分 档 案 局 概 况 一 主 要 职 责 二 部 门 决 算 单 位 构 成 第 二 部 分 档 案 局 2016 年 度 部 门 预 算 表 一 2016 年 度 市 级 部 门 收 支 预 算 总 表 二 2016 年 度 市 级 部 门 支 出 预 算 表 三 2016

目 录 第 一 部 分 档 案 局 概 况 一 主 要 职 责 二 部 门 决 算 单 位 构 成 第 二 部 分 档 案 局 2016 年 度 部 门 预 算 表 一 2016 年 度 市 级 部 门 收 支 预 算 总 表 二 2016 年 度 市 级 部 门 支 出 预 算 表 三 2016 档 案 局 2016 年 度 部 门 预 算 1 目 录 第 一 部 分 档 案 局 概 况 一 主 要 职 责 二 部 门 决 算 单 位 构 成 第 二 部 分 档 案 局 2016 年 度 部 门 预 算 表 一 2016 年 度 市 级 部 门 收 支 预 算 总 表 二 2016 年 度 市 级 部 门 支 出 预 算 表 三 2016 年 度 市 级 部 门 财 政 拨 款 支 出 预

More information