Microsoft PowerPoint - C++類別.ppt

Size: px
Start display at page:

Download "Microsoft PowerPoint - C++類別.ppt"

Transcription

1 C++ 的類別 (Class) 類別 (Class) 是一種資料型態, 可用來宣告物件 類別內含有資料成員 (Data member) 和成員函式 (Member function) 類別中不論是 Data Member 或 Member function 都可在 public 區或 private 區宣告 因 OOP 特性之一是隱藏資料, 一般會將 data member 以 private 方式宣告保護起來, 並將 member function 開放給外界操作 C++ 提供 Private, Protected 和 Public 來設定成員的保護等級 Private( 私有 ) 只有類別中的 member function 才可直接使用 ( 存取 ) 資料成員 Protected( 保護 ): 僅 member function 及繼承此類別之 member function 可直接使用資料成員 Public( 共用 ): 任何函式或敘述均可直接使用資料成員, 存取方式為物件. 成員 Class 預設的保護等級為 Private 類別函數的存取必須透過屬於該類別型態的物件和點運算子. 類別函數的取用方式 : o.f 或 p->f 其中 o 表物件名稱, f 表類別函數, p 表指標 定義在 Class 內的 function 為 inline function, 在 class 外每次呼叫該 function 時, 其 function code 會在呼叫處展開一次. P. 1 C++ 類別 (Class) Class Class 類別型態變數名稱 private: 私有資料成員變數之宣告 ;; 私有成員函式宣告及定義 ;; 公用成員函式 ;; 類別變數 ( 即物件 ( 即物件 ); ); data member stu1 average member function stu2 average newscore() printscore() //Page:7-4 class score float average; // 私有資料成員 void newscore(float avg) { average=avg; void printscore() { cout << Average of score: ; cout << average << endl; ; { score stu1,stu2; // 產生兩個物件 // 透過 member function 來存取 data member stu1.newscore(88.5); // 物件. Member function stu2.newscore(92.5); stu1.printscore(); stu2.printscore(); average=88.5; 錯誤的寫法 cout << average; P. 2 C++ 類別 (Class)

2 class Name char firstname[10]; char lastname[10]; void setname() { cout << "What's your first name:"; cin >> firstname; cout << "What's your last name:"; cin >> lastname; void printname() { cout << "\n The name is:" << firstname << ' ' << lastname << '\n'; ; { Name my_name; my_name.setname(); my_name.printname(); my_name data member firstname lastname Member function 若設計在 class 內, 呼叫此 member function 時 compiler 以 inline 方式處理 { Name my_name; // my_name.setname(); cout << "What's your first name:"; cin >> firstname; cout << "What's your last name:"; cin >> lastname; // my_name.printname(); cout << "\n The name is:" << firstname << ' ' << lastname << '\n'; member function setname() printname() P. 3 C++ 類別 (Class) Data member ( 資料成員 ) 的使用 data member 若在 private 區 僅可供 member function 直接取用 data member 若在 protected 區 可供 member function 直接取用 可供繼承此類別之類別其 member function 直接取用 data member 若在 public 區 可供 member function 直接取用 可供繼承此類別之類別其 member function 直接取用 可供一般的敘述或 function 以物件. 資料成員方式取用 Member function( 成員函式 ) 的使用 member function 若在 private 區 僅可供 member function 直接呼叫 member function 若在 protected 區 可供 member function 直接呼叫 可供繼承此類別之類別其 member function 直接呼叫 data member 若在 public 區 可供 member function 直接取用與繼承此類別之 member function 直接取用 可供一般的敘述或 function 以物件. 成員函數方式取用 P. 4 C++ 類別 (Class)

3 Class Base int a; void func1(){ protected: int b; void func2(){ int c; void func3(){ ; { 私有區 data 及 function 僅供自己類別內存取 保護區 data 及 function 僅供自己類別內及繼承之兒子存取 公用區 data 及 function 供所有敘述及函數存取 void void func1(){a=2; func1(){a=2; void void func2(){a=3; func2(){a=3; func1(); func1(); void void func3(){a=3; func3(){a=3; func1(); func1(); void main() {a=2; {a=2; func1(); func1(); void void func2(){b=2; func2(){b=2; void main() void void func3(){a=3; func3(){a=3; func1(); func1(); {b=2; {b=2; void void func3(){c=3; func3(){c=3; func1(); func1(); void main() void main() {base {base bs1; bs1; {{ base base bs1; bs1; c=2; c=2; bs1.c=3; bs1.c=3; func3(); func3(); bs1.func3(); bs1.func3(); P. 5 C++ 類別 (Class) //Private, Protected, Public 的差別 class test1 int a; void func1() { cout << "private function in test1\n"; protected: int b; void func2() { func1(); cout << "protected function in test1\n"; int c; void func3() { func2(); a=1;b=2;c=3; cout << "a=" << a << "b=" << b << "c=" << c << endl; void func4() { func3(); ; class test2:private test1 int d; void func5() { cout << "private function in test2\n"; int f; void func7() { // func1(); error! func2(); // a=4; error! b=5; c=6; ; { test1 t1; test2 t2; // t1.func1(); error! // t1.func2(); error! // t1.a=5; error! // t1.b=6; error! t1.c=7; t1.func3(); t2.func7(); P. 6 C++ 類別 (Class)

4 // Page 7-6 class score long number; float average; void newscore() // 輸入學號及平均 { cout << "enter number:"; cin >> number; cout << "enter average:"; cin >> average; void print_score() // 印出學號及平均 { cout << "student number is:" << number; cout << "student average:" << average; ; main() { score stu1,stu2; stu1.newscore(); stu2.newscore(); stu1.print_score(); stu2.print_score(); dinner // 類別的定義與使用 float ; // 長 float ; // 寬 void setlength(float le, float se) // 設定長寬 { =le; =se; void showsquare() // 計算面積並印出 { cout << * << endl; dinner; { dinner.setlength(5.0,3.5); P. 7 C++ 類別 (Class) // 類別的定義與使用 Page:7-10 /* data member 之值可以在 class 變數宣告時給值, 亦可透過 member function 供使用者輸入 */ float ; float ; void setlength(float le, float se) { =le; =se dinner living void getlength() { cout << "Input large edge:"; cin >> ; cout << "Input small edge:"; cin >> ; void showsquare() { cout << * << endl; dinner; { room living; dinner.setlength(3.2,3.1); living.getlength(); cout << "Square of dinner room is:"; cout << "Square of living room is:"; living.showsquare(); P. 8 C++ 類別 (Class)

5 雙冒號 :: 是範圍解析算符 (Scope resolution operator), 可用來表明該函式是屬於那一個類別的成員 當我們在類別以外的地方定義函式內容時, 一定要用 :: 來指明所屬的類別 而呼叫此成員函式的方式為非 inline 方式 class ID { int id_no; void set(int i) { id_no=i; ; int get() { return(id_no); class ID { int id_no; void set(int i); int get(); ; void ID::set(int i) { id_no=i; int ID::get() { return id_no; class ID { int id_no; void set(int i); int get(); ; inline void ID::set(int i) { id_no=i; int ID::get() { return id_no; P. 9 C++ 類別 (Class) 類別函數的存取必須透過屬於該類別型態的物件和點運算子. 類別函數的取用方式 : o.f 或 p->f 其中 o 表物件名稱, f 表類別函數, p 表指標 class ID { private: int id_no; void set(int i) { id_no=i; { ID o1,o2,*p=&o2; o1.set(1); p->set(2); cout << "o1=" << o1.get() << endl; cout << "o2=" << o2.get() << endl; cout << "*p=" << p->get() << endl; o o id_no id_no int get() { return(id_no); ; p 0020 P. 10 C++ 類別 (Class)

6 建構函數的名稱必須與類別名稱相同 建構函數不能有傳回值 建構函數可以接受參數以作為資料成員設定初值之用 在宣告類別變數 ( 物件 ) 時, 系統會自動執行建構函數 // 不用建構函數來設定初值的方法 float ; // 長 float ; // 寬 void setlength(float le, float se) // 設定長寬 { =le; =se; void showsquare() // 計算面積並印出 { cout << * << endl; ; { room dinner; dinner.setlength(5.0,3.5); 類別的建構函數與解建構函數 // 用建構函數來設定初值的方法 float,; room() { =6.0; =4.8; void showsquare() { cout << * < endl; ; { room dinner; cout << "square of dinner room is:"; P. 11 C++ 類別 (Class) 建構函數可以接受參數以作為資料成員設定初值之用 在指定物件初始值時, 可以用 = 初值 或 ( 初值 ) 來表明, 但若同時要設定多個資料成員的初值, 只有用小括號方式才行. // 用建構函數之參數來設定初值的方法 // 一個初值的設定 float edge; room(float a) { edge=a; void showsquare() { cout << edge * edge << endl; ; { room dinner=6.0,living(5.0); cout << "square of dinner room is:"; cout << "square of living room is:"; living.showsquare(); // 用建構函數之參數來設定初值的方法 // 兩個以上的初值 //Page: 7-29 float,; room(float le,float se) { =le; =se; void showsquare() { cout << * << endl; ; { room dinner(6.5,4.8); cout << "square of dinner room is:"; P. 12 C++ 類別 (Class)

7 // 用建構函數範例 Page:7-18,7-25 #include <conio.h> class counter unsigned int count; counter() // constructor { count=0; void countchar(); int getcount() { return count; ; void counter::countchar() { char ch; cout << "\nplease enter a string: \n"; while ((ch=getche())!='\r') { count++; { counter c1; c1.countchar(); cout << "\n Consists " << c1.getcount(); cout << "characters" << endl; 一個類別可以有一個以上的 constructor 我們稱為 overloaded constructor, 只要 constructor 之引數個數或資料型態不一樣, 則 compiler 便可視為不同之 constructor class String { char *str; String(); String(char *); void print() { cout << str << endl; ; String::String() { str="abcde"; String::String(char *ptr) { str=ptr; {String a; // call String() String b("xyz"); // call String(char *) a.print(); b.print(); P. 13 C++ 類別 (Class) 另一種 Constructor 初始值的設定方法 : 將初值設定在 constructor 之引數中, 呼叫時有設初值的引數可省略不寫 class Time int hour,minute,second; Time(int hr=0, int min=0,int sec=0) { hour=hr; minute=min; second=sec; void print() { cout << hour << ":" << minute << ":" << second << endl; ; {Time t1,t2(2),t3(21,34),t4(12,25,42); t1.print(); t2.print(); t3.print(); t4.print(); class Time int hour,minute,second; Time(int hr, int min,int sec) { hour=hr; minute=min; second=sec; void set(int hr, int min, int sec) {hour=hr; minute=min; second=sec; void print() { cout << hour << ":" << minute << ":" << second << endl; ; {Time t1,t2(2),t3(21,34) // error! Time t4(12,25,42); t4.print(); t4.set(13,24,55); t4.print(); P. 14 C++ 類別 (Class)

8 建構函數會在物件宣告後自動執行, 可以有參數但不可有傳回值 解建構函數 (Destructor) 會在物件消失時自動執行 解建構函數不可有參數亦不可有傳回值 解建構函數的名稱和類別名稱相同, 但其前須加上 ~ 符號 解建構函數之執行會將建構函數所配置的物件記憶體空間釋回 //7-22 float,; room() { =6.0; =4.8; float showsquare() { return * ; ~room() { cout << "Object deallocated"; ; { room dinner; cout << "square of dinner room is:"; cout << dinner.showsquare() << endl; dinner P. 15 C++ 類別 (Class) 以物件作為函數之參數 r r2 r3 //7-32 #include <iomanip.h> float,; room() { room(float le,float se) { =le; =se; void getlength() // 輸入物件長與寬 { cout << "Input large edge:"; cin >> ; cout << "Input small edge:"; cin >> ; void showsquare() // 計算面積並顯示 { cout << setprecision(3) << * << endl; void addsquare(room r1,room r2); ; void room::addsquare(room r1,room r2) // 將 r1 及 r2 兩物件之長寬分別加總後 // 存入本物件之長與寬並印出本物件周長 { =r1.+r2.; =r1.+r2.; cout << endl << "Total of room length: "; cout << setprecision(3) << (+)*2 << endl; ; { room r2,r3; room r1(3.2,2.1); r2.getlength(); cout << "\nsquare of r1 room is: "; r1.showsquare(); cout << "\nsquare of r2 room is: "; r2.showsquare(); cout << "\nsquare of r3 room is: "; r3.addsquare(r1,r2); P. 16 C++ 類別 (Class)

9 以物件作為函數之傳回值 r r2 r3 //7-37 temp #include <iomanip.h> float ; float ; room() { room(float le,float se) // 供宣告物件時給長寬值 { =le; =se; void getlength() // 供輸入長寬值 { cout << "Input large edge:"; cin >> ; cout << "Input small edge:"; cin >> ; void showlength() // 顯示物件周長 { cout << "Total of room length: << setprecision(3) << (+)*2 << endl; room tlength(room r2) // 將物件 r2 之長寬加上本物件之長寬並 // 存入 temp 物件之長寬後傳回 temp 物件 { room temp; temp.=+r2.; temp.=+r2.; return temp; ; { room r2; room r1(10.2,5.3); cout << "Length of r2 room:\n"; r2.getlength(); room r3=r1.tlength(r2); r3.showlength(); P. 17 C++ 類別 (Class) C++ 之動態記憶體配置 C 之動態記憶體配置函數為指標變數 =malloc( 容量 ) 及 free( 指標變數 ), malloc 通常搭配 sizeof( 型態變數 ) 以配置程式師所指定的記憶體容量 例如 : int *ptr; ptr=(int) malloc(10*sizeof(int)); 2 bytes 20 bytes 以 sizeof 將 int 之 bytes 數算出, 以 malloc 將使電腦配置 20 bytes 記憶體並將起始位址存入指標變數 ptr 中 C++ 之動態記憶體配置指令為為 New 與 Delete 可眚略 格式一 : 指標變數 = new 基本型態變數 [ 個數 ] 格式二 : 指標變數 = new 自定型態變數 ( 初始化之值 ) 將 new 所配置之記憶體釋回 : delete 指標變數例 : int *ptr; 例 : float *ptr; ptr=new int [100]; ptr=new float (3.14);... delete ptr; delete ptr P. 18 C++ 類別 (Class)

10 通常利用 constructor 來配置記憶體, 並利用 destructor 來釋回 #include <string.h> class Strings char *str; Strings() { strcpy(str,""); Strings(char *st) { str=new char[strlen(st)+1]; strcpy(str,st); ~Strings() { delete str; void set(char *ptr) { str=new char[strlen(ptr)+1]; strcpy(str,ptr); void printstr() { cout << str << endl; ; { char *title="london bridge is falling down!"; Strings ps1; // call String() ps1.set("london bridge"); / /use m.f. for initial ps1.printstr(); Strings ps2(title); // call Strings(char *st) for initial ps2.printstr(); Strings ps3("falling down"); //call String(char *st) ps3.printstr(); for initial Strings ps4="is falling down"; //call String(char *st) ps4.printstr(); for initial P. 19 C++ 類別 (Class) 成員的初始化串列 當我們用類別來定義物件時, 系統會先為類別內的資料成員配置好記憶體空間, 然後再呼叫適當的建構函數來設定初值 然而, 有時我們會希望系統在配置空間時能同時作初始化的工作, 這時就可以用 成員初始化串列 成員初始化串列必須出現在 constructor 的定義 ( 而非宣告 ) 之中 : constructor 名稱 ( 參數 ): 資料成員名稱 ( 初值運算式 )... #include <conio.h> class Test 配置順序 int i; int &ri; const int ci; Test(int a, int &b, int c); void Put() { cout << "i=" << i << endl; cout << "ri=" << ri << endl; cout << "ci=" << ci << endl; ; Test::Test(int a, int &b, int c) : ri(b),ci(c) { i=a; { clrscr(); int k=4; Test t1(2,k,6); t1.put(); 初始化串列 Output: i=2 ri=4 ci=6 建立 i 之空間 建立 ri, 並設定 ri 為 b 之 reference( 綽號 ) 建立 ci, ci c 執行 constructor, i a t1 P. 20 C++ 類別 (Class) i ri ci 每個資料成員在串列中最多只能出現一次, 初值的運算可以是常數 變數或複雜運算式, 其排列次序不重要, 系統為資料配置時依他們在類別定義 ( 宣告 ) 中出現的順序來執行 k

untitled

untitled 1 7 7.1 7.2 7.3 7.4 7.5 2 7.1 VFT virtual 7.1 3 1 1. 2. public protected public 3. VFT 4. this const volatile 4 2 5. ( ) ( ) 7.1 6. no-static virtual 7.2 7. inline 7.3 5 3 8. this this 9. ( ) ( ) delete

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

沒有投影片標題

沒有投影片標題 C++ 類 (Class Inheriance) : 料 ( 異 ), 類 料, 利 類 狀, 不 更 來 data membermember function 類 料 類 類 (Base class) 類, 類 類 (Derived class) 類 利 料 料, 料 不 料, 料 料, 留 類 類, 料, 類 來 類 列 更 類 數 例 : 類 數 類 料 例, String 類, 類 料, 串

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

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

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

新版 明解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 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++ 程式設計

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

untitled

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

More information

Strings

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

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

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

FY.DOC

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

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

untitled

untitled 不 料 料 例 : ( 料 ) 串 度 8 年 數 串 度 4 串 度 數 數 9- ( ) 利 數 struct { ; ; 數 struct 數 ; 9-2 數 利 數 C struct 數 ; C++ 數 ; struct 省略 9-3 例 ( 料 例 ) struct people{ char name[]; int age; char address[4]; char phone[]; int

More information

提问袁小兵:

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

More information

Microsoft PowerPoint - string_kruse [兼容模式]

Microsoft PowerPoint - string_kruse [兼容模式] Strings Strings in C not encapsulated Every C-string has type char *. Hence, a C-string references an address in memory, the first of a contiguous set of bytes that store the characters making up the string.

More information

C语言的应用.PDF

C语言的应用.PDF AVR C 9 1 AVR C IAR C, *.HEX, C,,! C, > 9.1 AVR C MCU,, AVR?! IAR AVR / IAR 32 ALU 1KBytes - 8MBytes (SPM ) 16 MBytes C C *var1, *var2; *var1++ = *--var2; AVR C 9 2 LD R16,-X ST Z+,R16 Auto (local

More information

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

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

epub 33-8

epub 33-8 8 1) 2) 3) A S C I I 4 C I / O I / 8.1 8.1.1 1. ANSI C F I L E s t d i o. h typedef struct i n t _ f d ; i n t _ c l e f t ; i n t _ m o d e ; c h a r *_ n e x t ; char *_buff; /* /* /* /* /* 1 5 4 C FILE

More information

第七讲 继承与多态

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

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

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 - 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

PowerPoint Presentation

PowerPoint Presentation 第六章簡介運算子超載 (Operator Overloading) 6-1 運算子超載的基礎 6-2 超載二元運算子 6-3 超載邏輯與關係運算子 6-4 超載一元運算子 6-5 使用夥伴函數 6-6 細部檢視指定運算子 6-7 超載註標運算子 6-1 運算子超載的基礎 甚麼是運算子超載? 讓運算子 ( 符號 ) 有不同的意義 EX: 運算子的預設意義 ( 以 + 與 = 為例 ) class frac

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

第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

The Embedded computing platform

The Embedded computing platform 嵌入式系統及實驗 Embedded System and Experiment 詹曉龍 長庚大學電機系 Java 的類別與物件 : 宣告類別 建構子 public class Customer { private String name; private String address; // Customer 類別宣告 // 成員資料 public int age; // 建構子 : 使用參數設定成員資料初始值

More information

相 应 功 能 (5) 再 将 Boy 类 作 为 Girl 类 的 友 元 类, 在 Boy 类 的 某 成 员 函 数 VisitGirl(Girl & ) 中 访 问 Girl 类 的 私 有 成 员, 观 察 编 译 器 给 出 的 信 息 ( 6 ) 删 除 两 个 类 中 的 函 数 V

相 应 功 能 (5) 再 将 Boy 类 作 为 Girl 类 的 友 元 类, 在 Boy 类 的 某 成 员 函 数 VisitGirl(Girl & ) 中 访 问 Girl 类 的 私 有 成 员, 观 察 编 译 器 给 出 的 信 息 ( 6 ) 删 除 两 个 类 中 的 函 数 V 面 向 对 象 程 序 设 计 及 C++ 课 程 实 验 教 学 大 纲 课 程 编 号 : B030001S 课 程 名 称 : 面 向 对 象 程 序 设 计 及 C++ 课 内 总 学 时 : 3 上 机 实 验 学 时 : 8 一 实 验 课 程 的 性 质 目 的 和 任 务 性 质 : 本 实 验 课 程 是 本 科 理 工 科 各 专 业 学 生 的 通 识 基 础 课, 该 实 验

More information

Microsoft Word - 97.01.30軟體設計第二部份範例試題_C++_ _1_.doc

Microsoft Word - 97.01.30軟體設計第二部份範例試題_C++_ _1_.doc 電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 範 例 試 題 (C++) 試 題 編 號 :11900-920201-4 審 定 日 期 : 94 年 7 月 1 日 修 訂 日 期 : 96 年 2 月 1 日 97 年 1 月 30 日 ( 第 二 部 份 ) 電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 應 檢 參 考 資 料 壹 試

More information

Strings

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

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

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; Memory & Pointer trio@seu.edu.cn 2.1 2.1.1 1 int *p int a 0x00C7 0x00C7 0x00C7 2.1.2 2 int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; 2.1.3 1. 2. 3. 3 int A,

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

A.doc

A.doc A CopyRight: 2003, Mahler Works C > 1.1 C (5 min) 1.1.1C 1.1.21998 ANSIAmerican National Standards InsituteISO International Standards Organzation 1.1.3C/C++C C 1.1.4 C JAVA PLATFORM C 1.2 (5 min)

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

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

主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new

主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new ListView 自訂排版 主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new int[]{r.drawable.dog1, R.drawable.dog2,

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

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

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

投影片 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

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

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

More information

<4D6963726F736F667420506F776572506F696E74202D20332D322E432B2BC3E6CFF2B6D4CFF3B3CCD0F2C9E8BCC6A1AAD6D8D4D8A1A2BCCCB3D0A1A2B6E0CCACBACDBEDBBACF2E707074>

<4D6963726F736F667420506F776572506F696E74202D20332D322E432B2BC3E6CFF2B6D4CFF3B3CCD0F2C9E8BCC6A1AAD6D8D4D8A1A2BCCCB3D0A1A2B6E0CCACBACDBEDBBACF2E707074> 程 序 设 计 实 习 INFO130048 3-2.C++ 面 向 对 象 程 序 设 计 重 载 继 承 多 态 和 聚 合 复 旦 大 学 计 算 机 科 学 与 工 程 系 彭 鑫 pengxin@fudan.edu.cn 内 容 摘 要 方 法 重 载 类 的 继 承 对 象 引 用 和 拷 贝 构 造 函 数 虚 函 数 和 多 态 性 类 的 聚 集 复 旦 大 学 计 算 机 科 学

More information

OOP with Java 通知 Project 4: 4 月 18 日晚 9 点 关于抄袭 没有分数

OOP with Java 通知 Project 4: 4 月 18 日晚 9 点 关于抄袭 没有分数 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 4: 4 月 18 日晚 9 点 关于抄袭 没有分数 复习 类的复用 组合 (composition): has-a 关系 class MyType { public int i; public double d; public char c; public void set(double

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

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

Microsoft Word - chap10.doc

Microsoft Word - chap10.doc 78 10. Inheritance in C++ 我 們 已 介 紹 了 物 件 導 向 程 式 的 第 一 個 主 要 特 性, 即 程 式 可 模 組 化 成 為 類 別 ( 物 件 ), 類 別 具 有 資 料 封 裝 的 特 性 接 下 來 我 們 要 介 紹 物 件 導 向 程 式 的 另 一 個 主 要 特 性, 那 就 是 類 別 具 有 繼 承 的 功 能 繼 承 就 是 重 複

More information

Microsoft Word - 物件導向編程精要.doc

Microsoft Word - 物件導向編程精要.doc Essential Object-Oriented Programming Josh Ko 2007.03.11 object-oriented programming C++ Java OO class object OOP Ruby duck typing complexity abstraction paradigm objects objects model object-oriented

More information

C 1

C 1 C homepage: xpzhangme 2018 5 30 C 1 C min(x, y) double C // min c # include # include double min ( double x, double y); int main ( int argc, char * argv []) { double x, y; if( argc!=

More information

nooog

nooog C : : : , C C,,, C, C,, C ( ), ( ) C,,, ;,, ; C,,, ;, ;, ;, ;,,,, ;,,, ; : 1 9, 2 3, 4, 5, 6 10 11, 7 8, 12 13,,,,, 2008 1 1 (1 ) 1.1 (1 ) 1.1.1 ( ) 1.1.2 ( ) 1.1.3 ( ) 1.1.4 ( ) 1.1.5 ( ) 1.2 ( ) 1.2.1

More information

HR HR

HR HR HR Training HR Dept 2005-2-6 HR HR + =150 23% 2% 29% 46% 19% 81% 30-39 41% 50 3% 40-49 5% 20-29 51% 20-29 30-39 40-49 50 HR 2 26 25 18 BSC 1 2004 % % 20.0% 401 8.0% 160 10.0% 200 2.0% 40 1.5% 30 0.5%

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

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc 2 5 8 11 0 13 1. 13 2. 15 3. 18 1 23 1. 23 2. 26 3. 28 2 36 1. 36 2. 39 3. 42 4. 44 5. 49 6. 51 3 57 1. 57 2. 60 3. 64 4. 66 5. 70 6. 75 7. 83 8. 85 9. 88 10. 98 11. 103 12. 108 13. 112 4 115 1. 115 2.

More information

Microsoft Word - 01.DOC

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

More information

Template

Template 第十一章 ( 上篇 ) 函數樣板 (Function Template) 與 類別樣板 (Class Template) 建立通用函數 (Generic Functions) & 通用類別 (Generic Classes) - Code Reuse 的另一種發揮 - 煩人的事經歷一次就夠了 1 為何需要通用函數? int abs(int x) { return (x>0)?x:-x; int abs(int

More information

Microsoft PowerPoint - STU_C_Lang_CH13.ppt

Microsoft PowerPoint - STU_C_Lang_CH13.ppt 第 13 章 動態配置記憶體 程式設計與生活 - 使用 C 語言 Shi-Huang Chen Spring 2013 第 13 章 動態配置記憶體 13-1 記憶體配置函式 malloc( ) 13-2 動態配置結構陣列 配置記憶體 預估需求數量的範圍是一項不容易的學問 例 : 大到預估今年國家預算, 小到預估櫥窗裡展示的毛線衣, 需要多少磅毛線才能織成 撰寫程式時, 一樣無法預估程式執行所需的記憶體空間

More information

Microsoft Word - 970617cppFinalSolution.doc

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

More information

運算子多載 Operator Overloading

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

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

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

用户大会 论文集2.2.doc

用户大会 论文集2.2.doc MagGis MapGis GIS MagGis API DLL MapGis VC++ VB BC++ Delphi., Windows API MapGis VC++V Delphi Delphi Delphi MapGis Delphi Delphi Windows Delphi Delphi MapGis MapGis DLL API MapGis function _InitWorkArea(HINST:Integer):Integer;

More information

第1章

第1章 第 9 章 類別 1 本章提要 9.1 前言 9.2 物件導向程式設計基礎 9.3 類別的基本認識 9.4 公有成員與私有成員 9.5 類別變數與類別方法 9.6 進一步認識方法 9.7 進一步認識建構元 9.8 其它 9.9 綜合練習 9.10 後記 2 9.1 前言 物件導向程式設計的特性主要有 : 分而治之 (Divide and Conquer) 資訊隱藏 (Information Hiding)

More information

untitled

untitled Introduction to Programming ( 數 ) Lecture 3 Spring 2005 March 4, 2005 Lecture 2 Outline 數 料 If if 狀 if 2 (Standard Output, stdout): 料. ((Standard Input, stdin): 料. 類 數 數 數 說 printf 見 數 puts 串 數 putchar

More information

C/C++语言 - 分支结构

C/C++语言 - 分支结构 C/C++ Table of contents 1. if 2. if else 3. 4. 5. 6. continue break 7. switch 1 if if i // colddays.c: # include int main ( void ) { const int FREEZING = 0; float temperature ; int cold_ days

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

OOP with Java 通知 Project 4: 4 月 19 日晚 9 点

OOP with Java 通知 Project 4: 4 月 19 日晚 9 点 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 4: 4 月 19 日晚 9 点 复习 类的复用 组合 (composition): has-a 关系 class MyType { public int i; public double d; public char c; public void set(double x) { d

More information

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023)

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023) ( CIP) /. :, 2005. 2 ( ) ISBN 7-5624-3339-9.......... TP311. 1 CIP ( 2005) 011794 : : : : * : : 174 ( A ) :400030 : ( 023) 65102378 65105781 : ( 023) 65103686 65105565 : http: / /www. cqup. com. cn : fxk@cqup.

More information

踏出C++的第一步

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

More information

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit 6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C51 6.1 C51 6.1.1 C51 C51 ANSI C MCS-51 C51 ANSI C C51 6.1 6.1 C51 bit Byte bit sbit 1 0 1 unsigned char 8 1 0 255 Signed char 8 11 128

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

概述

概述 OPC Version 1.6 build 0910 KOSRDK Knight OPC Server Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOS_Init...5 2.2.2 KOS_InitB...5 2.2.3

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

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F 1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET 2.0 2.0.NET Framework.NET Framework 2.0 ( 3).NET Framework 2.0.NET Framework ( System ) o o o o o o Boxing UnBoxing() o

More information

第1章

第1章 第 8 章 函式 1 本章提要 8.1 前言 8.2 如何定義函式 8.3 函式的呼叫和返回 8.4 傳遞陣列 8.5 方法多載 8.6 遞迴 8.7 綜合練習 8.8 後記 2 8.1 前言 每一種高階程式語言都有提供函式 (Function)( 或稱函數 ) 的功能, 以便將經常使用到的程式功能包裝成函式的形式, 如此一來便能反覆地呼叫該函式來完成某件特定工作在高階程式語言中, 副程式 (Subroutine)

More information

Microsoft PowerPoint - plan08.ppt

Microsoft PowerPoint - plan08.ppt 程 序 设 计 语 言 原 理 Principle of Programming Languages 裘 宗 燕 北 京 大 学 数 学 学 院 2012.2~2012.6 8. 面 向 对 象 为 什 么 需 要 面 向 对 象? OO 语 言 的 发 展 面 向 对 象 的 基 本 概 念 封 装 和 继 承 初 始 化 和 终 结 处 理 动 态 方 法 约 束 多 重 继 承 总 结 2012

More information

詞 彙 表 編 號 詞 彙 描 述 1 預 約 人 資 料 中 文 姓 名 英 文 姓 名 身 份 證 字 號 預 約 人 電 話 性 別 2 付 款 資 料 信 用 卡 別 信 用 卡 號 信 用 卡 有 效 日 期 3 住 房 條 件 入 住 日 期 退 房 日 期 人 數 房 間 數 量 入

詞 彙 表 編 號 詞 彙 描 述 1 預 約 人 資 料 中 文 姓 名 英 文 姓 名 身 份 證 字 號 預 約 人 電 話 性 別 2 付 款 資 料 信 用 卡 別 信 用 卡 號 信 用 卡 有 效 日 期 3 住 房 條 件 入 住 日 期 退 房 日 期 人 數 房 間 數 量 入 100 年 特 種 考 試 地 方 政 府 公 務 人 員 考 試 試 題 等 別 : 三 等 考 試 類 科 : 資 訊 處 理 科 目 : 系 統 分 析 與 設 計 一 請 參 考 下 列 旅 館 管 理 系 統 的 使 用 案 例 圖 (Use Case Diagram) 撰 寫 預 約 房 間 的 使 用 案 例 規 格 書 (Use Case Specification), 繪 出 入

More information

Microsoft PowerPoint - C-Ch08.ppt

Microsoft PowerPoint - C-Ch08.ppt 函數 8-1 函數 函數 (function) 可以整合某些特定的處理 整合好的處理可以隨時呼叫使用 C 語言的程式本身也是一個函數, 也就是 main() 函數 使用函數可簡化程式 提款的處理 1. 將提款卡插入自動提款機當中 2. 輸入個人密碼 3. 指定提款金額 4. 領取款項 5. 確認款項與提款卡 提款處理 8-2 函數的定義與呼叫 定義函數的語法 : 傳回值的型態函數名稱 ( 引數列表

More information

untitled

untitled 1 1.1 1.2 1.3 1.4 1.5 ++ 1.6 ++ 2 BNF 3 4 5 6 7 8 1.2 9 1.2 IF ELSE 10 1.2 11 1.2 12 1.3 Ada, Modula-2 Simula Smalltalk-80 C++, Objected Pascal(Delphi), Java, C#, VB.NET C++: C OOPL Java: C++ OOPL C# C++

More information

2012 3 A 1 (T65C 1) 0.6 0.4 15. 8 7.2 0.7 2.3 ; (T65C 1) A (T65C 1) 7.2 2.2 1.6 7.2 2.4 0.8 5.4 ( ~ 1) A (T65C 1) A (T96B 3) A (T96B 3) 1 (T96B 3) 0.8

2012 3 A 1 (T65C 1) 0.6 0.4 15. 8 7.2 0.7 2.3 ; (T65C 1) A (T65C 1) 7.2 2.2 1.6 7.2 2.4 0.8 5.4 ( ~ 1) A (T65C 1) A (T96B 3) A (T96B 3) 1 (T96B 3) 0.8 ( ) () 2009 7 ~2010 8 12 ( ) 3000 [1] 12 5.5 A B A 7 3 41 2012 3 A 1 (T65C 1) 0.6 0.4 15. 8 7.2 0.7 2.3 ; (T65C 1) A (T65C 1) 7.2 2.2 1.6 7.2 2.4 0.8 5.4 ( ~ 1) A (T65C 1) A (T96B 3) A (T96B 3) 1 (T96B

More information

Microsoft PowerPoint - 20-string-s.pptx

Microsoft PowerPoint - 20-string-s.pptx String 1 String/ 1.: char s1[10]; char *s2; char s3[] = "Chan Tai Man"; char s4[20] = "Chan Siu Ming"; char s5[]={'h','e','l','l','o','\0'; 0 1 2 3 4 5 6 7 8 9 10 11 12 s3 C h a n T a i \0 M a n \0 printf

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

致遠管理學院法規提案單

致遠管理學院法規提案單 台 灣 首 府 大 學 101 學 年 度 第 2 學 期 第 1 次 行 政 會 議 會 議 議 程 會 議 資 料 請 先 行 參 閱 為 方 便 討 論, 請 於 開 會 當 日 攜 帶 與 會, 謝 謝 您 的 合 作 若 不 克 與 會, 請 於 事 前 告 知 承 辦 人 ( 分 機 215 詹 琬 渝 ) 會 議 時 間 : 民 國 102 年 2 月 6 日 ( 星 期 三 ) 下

More information

プリント

プリント For Higher Customer Satisfaction, We Bridge the SAS System Between Customer s World. YourModelsBuild up Your NextAnalytics 02 Y β0 β1x1 β2x2 ε Y ~ μ σ 2 μ β0 β1x1 β2x2 Y ~ n p logit(p) β0 β1x1 β2x2 logit(p)logit(p)=log(p/(1-p))

More information

Microsoft PowerPoint - 10 模板 Template.pptx

Microsoft PowerPoint - 10 模板 Template.pptx 模板 Tempalte 泛型编程的需要 Why Templates? 设想你对整数类型实现了一个排序算法 : void sort(int *is,int n); 用该函数可以对实 复数或工资单排序吗? 模板可以复用源代码 - 泛型编程. inline void Swap( int &x, int &y){ int t = x; x = y; y =t; inline void Swap(double

More information

新・明解C言語入門編『索引』

新・明解C言語入門編『索引』 !... 75!=... 48 "... 234 " "... 9, 84, 240 #define... 118, 213 #include... 148 %... 23 %... 23, 24 %%... 23 %d... 4 %f... 29 %ld... 177 %lf... 31 %lu... 177 %o... 196 %p... 262 %s... 242, 244 %u... 177

More information

Microsoft Word - CPE考生使用手冊160524.docx

Microsoft Word - CPE考生使用手冊160524.docx 大 學 程 式 能 力 檢 定 (CPE) 考 生 使 用 手 冊 2016 年 5 月 24 日 這 份 手 冊 提 供 給 參 加 CPE 檢 定 考 試 的 考 生 內 容 包 含 考 試 環 境 的 使 用, 以 及 解 題 時 所 使 用 I/O 的 基 本 知 識 1. 如 欲 報 名 參 加 CPE 考 試, 請 先 於 CPE 網 站 完 成 帳 號 註 冊, 然 後 再 報 名 該

More information

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc 2 5 8 11 0 1. 13 2. 15 3. 18 1 1. 22 2. 25 3. 27 2 1. 35 2. 38 3. 41 4. 43 5. 48 6. 50 3 1. 56 2. 59 3. 63 4. 65 5. 69 13 22 35 56 6. 74 7. 82 8. 84 9. 87 10. 97 11. 102 12. 107 13. 111 4 114 1. 114 2.

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 177 [P179] (1) - [P181] [P182] (2) - for [P183] (3) - switch [P184] [P187] [P189] [P194] 178 [ ]; : : int var; : int var[3]; var 2293620 var[0] var[1] 2293620

More information

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File 51 C 51 51 C C C C C C * 2003-3-30 pnzwzw@163.com C C C C KEIL uvision2 MCS51 PLM C VC++ 51 KEIL51 KEIL51 KEIL51 KEIL 2K DEMO C KEIL KEIL51 P 1 1 1 1-1 - 1 Project New Project 1 2 Windows 1 3 N C test

More information

OOP with Java 通知 Project 4: 5 月 2 日晚 9 点

OOP with Java 通知 Project 4: 5 月 2 日晚 9 点 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 4: 5 月 2 日晚 9 点 复习 类的复用 组合 (composition): has-a 关系 class MyType { public int i; public double d; public char c; public void set(double x) { d =

More information

Microsoft Word - data_mid1611_and_sol.docx

Microsoft Word - data_mid1611_and_sol.docx Department of Computer Science and Engineering National Sun Yat-sen University Data Structures - Middle Exam, Nov. 14, 2016 1. Explain each of the following terms. (16%) (a) private in C++ language (b)

More information

Microsoft Word - MSP430 Launchpad 指导书.docx

Microsoft Word - MSP430 Launchpad 指导书.docx Contents 3... 9... 14 MSP430 LAUNCHPAD 指导书 3 第一部分第一个工程 New Project File > New > CCS Project Project name: ButtonLED Device>Family: MSP430 Variant: MSP430G2553 Project templates and examples : Empty Project

More information

Microsoft PowerPoint - ch04_AEL0080.ppt

Microsoft PowerPoint - ch04_AEL0080.ppt 4 選擇 在正常的情況下, 電腦程式的執行是以敘述的排列次序逐步處理的 使用控制架構 (control structures) 可以改變這種既定的先後次序, 讓程式得以進行更複雜的運算, 或以更簡潔的指令來實現演算法 1/42 選擇 4.1 演算法的描述方式 4.2 變數的運用範圍 (Scope of variables) 4.3 if- 敘述 4.4 巢狀 if- 敘述 (Nested if statements)

More information

51 C 51 isp 10 C PCB C C C C KEIL

51 C 51 isp 10   C   PCB C C C C KEIL http://wwwispdowncom 51 C " + + " 51 AT89S51 In-System-Programming ISP 10 io 244 CPLD ATMEL PIC CPLD/FPGA ARM9 ISP http://wwwispdowncom/showoneproductasp?productid=15 51 C C C C C ispdown http://wwwispdowncom

More information

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

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

More information

2000 / / % 0.035% % % % 3 2 ETF creation / redemption TTT ETF 3 / -1 2

2000 / / % 0.035% % % % 3 2 ETF creation / redemption TTT ETF 3 / -1 2 1 ETF TTT ETF 50 TTT TTT ETF 1 TTT 1.1 TTT 50 TTT 2003 6 30 TTT ETF 50 1 TTT 50 50 FTSE 17 1000 1 50 1 50 5 7% 9 00-1 30 1 ETF ETF ETF 1 2000 / 2 9 00-3 30 / 100 1.425 1 3 0.32% 0.035% 15 35 0.04% 15 85

More information

_汪_文前新ok[3.1].doc

_汪_文前新ok[3.1].doc 普 通 高 校 本 科 计 算 机 专 业 特 色 教 材 精 选 四 川 大 学 计 算 机 学 院 国 家 示 范 性 软 件 学 院 精 品 课 程 基 金 青 年 基 金 资 助 项 目 C 语 言 程 序 设 计 (C99 版 ) 陈 良 银 游 洪 跃 李 旭 伟 主 编 李 志 蜀 唐 宁 九 李 涛 主 审 清 华 大 学 出 版 社 北 京 i 内 容 简 介 本 教 材 面 向

More information