Microsoft PowerPoint - 6. 用户定义类型User-defined Datatypes.ppt [兼容模式]

Size: px
Start display at page:

Download "Microsoft PowerPoint - 6. 用户定义类型User-defined Datatypes.ppt [兼容模式]"

Transcription

1 用户定义类型 User-defined Datatypes classes and structs

2 几何向量 (Geometry Vector) 二维平面上的向量由起点和终点构成 每个点包含两个坐标 (x, y), 因此一个向量需要四个实数表示 Start= (0.9,1.5) Start= (0.4,0.8) int main() { double xstart = 0.4; double xend = 0.8; double ystart = 0.9; double yend = 1.5;

3 几何向量 (Geometry Vector) 传递一个向量给函数, 需要传递 4 个 double void printvector(double x0,double y0,double x1,double y1){ cout << "(" << x0 << "," << y0 << ") -> (" << x1 << "," << y1 << ")" << endl; int main( ) { double xstart = 0.4; double xend = 0.8; double ystart = 0.9; double yend = 1.5; printvector(xstart, ystart, xend, yend);

4 void offsetvector (double &x0, double &y0, double &x1, double &y1,double offsetx, double offsety) { x0 += offsetx; y0 += offsety; x1 += offsetx; y1 += offsety; void printvector(double x0,double y0,double x1,double y1){ cout << "(" << x0 << "," << y0 << ") -> (" << x1 << "," << y1 << ")" << endl; int main( ) { double xstart = 0.4; double xend = 0.8; double ystart = 0.9; double yend = 1.5; offsetvector(xstart, ystart, xend, yend,1.2, 2.3); printvector(xstart, ystart, xend, yend); 需要传递很多变量

5 类 class 用户定义类型用以将相关的信息组装在一起

6 类名 class Vector { double xstart ; double xend ; double ystart ; double yend ; 类 class 的定义语法 C++11 标准 class Vector { double xstart = 0.4; double xend = 0.8; double ystart = 0.9; double yend = 1.5; 表示定义一个叫做 Vector 的类, 即 Vector 是用户定义的一种新类型

7 类 class 的定义语法 class Vector { double xstart ; double xend ; double ystart ; double yend ; 类的属性也叫成员 表示定义一个叫做 Vector 的类, 即 Vector 是用户定义的一种新类型

8 Student class Student { char *name ; int stuid; 类类型 Student 具有 2 个不同类型的数据成员

9 类的实例 - 具体的类变量 class Student { char *name ; int stuid; void main( ){ Student stu1, stu2; stu1 stu2 name =? name =? stuid =? stuid =? 某种类类型的一个具体变量叫做这个类的一个实例

10 类的实例 - 具体的类变量 class Student { char *name ; int stuid; void main( ){ Student stu1, stu2; stu1.name = LiPin ; stu1 name = LiPin stu2 name =? stuid =? stuid =? 某种类类型的一个具体变量叫做这个类的一个实例

11 class Student { char *name ; int stuid; void main( ){ Student stu1, stu2; stu1.name = LiPin ; stu1.stuid = 1403; 类的实例 - 具体的类变量 stu1 name = LiPin stu2 name =? stuid = 1403 stuid =? 某种类类型的一个具体变量叫做这个类的一个实例

12 class Student { char *name ; int stuid; void main( ){ Student stu1, stu2; stu1.name = LiPin ; stu1.stuid = 1403; stu2.name = XuJie ; stu2.stuid = 1207; 类的实例 - 具体的类变量 stu1 name = LiPin stu2 name =XuJie stuid = 1403 stuid = 1207 某种类类型的一个具体变量叫做这个类的一个实例

13 操作成员 / 属性 (Accessing Fields) 通过 变量名. 成员名 来访问类实例的成员 ( 属性 ) clss Student { char *name ; int stuid; void main( ){ Student stu1, stu2; stu1.name = LiPin ; stu1.stuid = 1403; stu2.name = XuJie ; stu2.stuid = 1207; cout<< the name of stu1 is: << stu1.name<< \n ;

14 Point Vector 一个向量由 2 点 ( 起点和终点 ) 构成. class Point { double x,y; class Vector { Point start, end; void main() { Vector vec1; vec1.start.x = 3.0;

15 class Point { double x,y; class Vector { Point start, end; void main() { Vector vec1; vec1.start.x = 3.0; vec1.start.y = 4.0; vec1.end.x = 5.0; vec1.end.y = 6.0; Point Vector

16 class Point { double x,y; class Vector { Point start, end; void main() { Vector vec1; vec1.start.x = 3.0; vec1.start.y = 4.0; vec1.end.x = 5.0; vec1.end.y = 6.0; Vector vec2; vec2.start = vec1.start; vec2.start.x = 7.0; Point 类有 2 个成员 x,y Point 类的 2 个实例 start,end 作为类 Vector 的成员 Vector 类的实例 vec1. vec1 也称为类变量或对象

17 class Point { double x,y; class Vector { Point start, end; void main() { Vector vec1; vec1.start.x = 3.0; vec1.start.y = 4.0; vec1.end.x = 5.0; vec1.end.y = 6.0; Vector vec2; vec2.start = vec1.start; vec2.start.x = 7.0;

18 class Point { double x,y; class Vector { Point start, end; int main() { Vector vec; vec.start.x = 1.2; vec.end.x = 2.0; vec.start.y = 0.4; vec.end.y = 1.6;

19 class Point { double x,y; class Vector { Point start, end; void printvector(vector v) { cout << "(" << v.start.x << "," << v.start.y << ") -> (" << v.end.x << "," << v.end.y << ")" << endl; int main() { Vector vec; vec.start.x = 1.2; vec.end.x = 2.0; vec.start.y = 0.4; vec.end.y = 1.6; printvector(vec);

20 class Point { double x,y; class Vector { Point start, end; 如果不需要修改传进来的 v, 可以传值 void printvector(vector v) { cout << "(" << v.start.x << "," << v.start.y << ") -> (" << v.end.x << "," << v.end.y << ")" << endl; int main() { Vector vec; vec.start.x = 1.2; vec.end.x = 2.0; vec.start.y = 0.4; vec.end.y = 1.6; printvector(vec);

21 class Point { double x,y; class Vector { Point start, end; void offsetvector(vector &v, double offsetx, double offsety) { v.start.x += offsetx; v.end.x += offsetx; v.start.y += offsety; v.end.y += offsety; void printvector(vector v) { cout << "(" << v.start.x << "," << v.start.y << ") -> (" << v.end.x << "," << v.end.y << ")" << endl; int main() { Vector vec; vec.start.x = 1.2; vec.end.x = 2.0; vec.start.y = 0.4; vec.end.y = 1.6; offsetvector(vec, 1.0, 1.5); printvector(vec);

22 class Point { double x,y; class Vector { Point start, end; 如果要修改传进来的 v, 则传引用 void offsetvector(vector &v, double offsetx, double offsety) { v.start.x += offsetx; v.end.x += offsetx; v.start.y += offsety; v.end.y += offsety; void printvector(vector v) { cout << "(" << v.start.x << "," << v.start.y << ") -> (" << v.end.x << "," << v.end.y << ")" << endl; int main() { Vector vec; vec.start.x = 1.2; vec.end.x = 2.0; vec.start.y = 0.4; vec.end.y = 1.6; offsetvector(vec, 1.0, 1.5); printvector(vec);

23 类的函数成员 ( 方法 ) 类的方法 (Method) 是一种属于类的函数, 用于访问类的属性 ( 数据成员 ) Vector vec; vec.start.x = 1.2; vec.end.x = 2.0; vec.start.y = 0.4; vec.end.y = 1.6; vec.print(); vec.offset( 1.0, 1.5); 可给类方法传递参数 类的方法 (Method) 如同盒子 ( 类实例 ) 上的按钮, 当按钮被按下 ( 调用这个方法 ) 就盒子产生某种动作

24 类的函数成员 ( 方法 ) 类的方法 (Method) 如同盒子 ( 类实例 ) 上的按钮, 当按钮被按下 ( 调用这个方法 ) 就盒子产生某种动作

25 类的函数成员 ( 方法 ) 类的方法 (Method) 如同盒子 ( 类实例 ) 上的按钮, 当按钮被按下 ( 调用这个方法 ) 就盒子产生某种动作 哪一个盒子?

26 类的函数成员 ( 方法 ) 类的方法 (Method) 如同盒子 ( 类实例 ) 上的按钮, 当按钮被按下 ( 调用这个方法 ) 就盒子产生某种动作 哪一个按钮?

27

28 数据成员可以被方法访问

29 数据成员的方法也可以被调用

30 类方法的原型和实现的分离 如何函数的原型和实现可以分开一样, 类的函数成员 ( 方法 ) 与其原型也可以分离.h 头文件是函数原型说明,.cpp 文件是方法的实现

31

32 许多初始化是乏味的, 能否在定义类的实例时就自动进行初始化?

33 构造函数 (Constructors) 在类实例创建时自动调用的方法

34 可以接受参数 构造函数 (Constructors)

35 构造函数 (Constructors) 可以有多个构造函数

36 构造函数 (Constructors) 默认构造函数 : 无参数或参数有默认值的构造函数 class Point{ double x,y; Point(double nx = 0, double ny = 0) { x= nx; y= ny; int main(){ Point P, Q(1.2), R(2.6, 3);

37 构造函数 (Constructors) 一个类实例给另一个复制时, 将复制其每个成员 ( 调用默认拷贝构造函数 (default copy constructor))

38 构造函数 (Constructors) 你可以定义自己的拷贝构造函数

39 构造函数 (Constructors) 为何定义自己的拷贝构造函数? 默认的拷贝构造函数硬拷贝每个成员可能不是我们需要的! class Student { char *name ; int stuid; Student(){ name = ; stuid = 0; void main( ){ Student stu1; stu1.stuid = 98; char n[] = "foo"; stu1.name = n; Student stu2 = stu1; stu2.name[0] = 'b'; cout << stu1.name; //boo 对 stu2 的修改引起了 stu1 的改变!

40 构造函数 (Constructors) 为何定义自己的拷贝构造函数? 默认的拷贝构造函数硬拷贝每个成员可能不是我们需要的! class Student { char *name ; int stuid; Student(){ name = ; stuid = 0; Student(Student &o){ name = strdup(o.name); stuid = o. stuid ; void main( ){ Student stu1; stu1.stuid = 98; char n[] = "foo"; stu1.name = n; Student stu2 = stu1; stu2.name[0] = 'b'; cout << stu1.name; //foo 对 stu2 的修改不会改变 stu1!

41 初始化成员列表 构造函数 (Constructors) class Rectangle { int width,height; Rectangle(int,int); int area() {return width*height; Rectangle::Rectangle (int x, int y) { width=x; height=y;

42 初始化成员列表 构造函数 (Constructors) class Rectangle { int width,height; Rectangle(int,int); int area() {return width*height; Rectangle::Rectangle (int x, int y) : width(x) { height=y;

43 初始化成员列表 构造函数 (Constructors) class Rectangle { int width,height; Rectangle(int,int); int area() {return width*height; Rectangle::Rectangle (int x, int y) : width(x), height(y) {

44 构造函数 (Constructors) 对于没有默认构造函数的类成员, 该成员必须在初始化成员列表中初始化! class Circle { double radius; Circle(double r) : radius(r) { double area() {return radius*radius* ; class Cylinder { Circle base; double height; Cylinder(double r, double h) : base (r), height(h) { double volume() { return base.area() * height;

45 #include <iostream> int main () { Cylinder foo (10,20); std:: cout << "foo's volume: " << foo.volume() << '\n'; return 0;

46 访问修饰符 (Access Modifiers) 定义类的属性能被? 访问

47 访问修饰符 (Access Modifiers) public : 能从任何地方访问

48 访问修饰符 (Access Modifiers) private : 只能从类内部的方法访问

49 访问修饰符 (Access Modifiers) getters: 提供对私有数据成员的查询方法

50 默认的访问修饰符 (Default Access Modifiers) class: 默认是 private

51 默认的访问修饰符 (Default Access Modifiers) struct 默认是 public struct 是对 C 中的 struct 的扩展 ( 增加了方法 ) struct 和 class 都是定义类类型, 除了其默认访问修饰符不同!

52 默认的访问修饰符 (Default Access Modifiers) struct: 默认是 public class: 默认是 private

53 作业 定义一个表示三维向量类 Vector3, 能够完成常见的数学向量运算, 如加减 点积 差积 求长等

Strings

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

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

Microsoft PowerPoint - 8. 运算符重载 Operator Overloading.pptx

Microsoft PowerPoint - 8. 运算符重载 Operator Overloading.pptx 运算符重载 Operator Overloading class Point { public: ; double x_, y_; Why Operator Overloading? Point (double x =0, double y = 0):x_(x),y_(y) { int main(){ Point a(1., 2), b(3,4); Point c = a + b; return 0;

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

untitled

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

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

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

Strings

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

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

无类继承.key

无类继承.key 无类继承 JavaScript 面向对象的根基 周爱 民 / aimingoo aiming@gmail.com https://aimingoo.github.io https://github.com/aimingoo rand = new Person("Rand McKinnon",... https://docs.oracle.com/cd/e19957-01/816-6408-10/object.htm#1193255

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

OOP with Java 通知 Project 3: 3 月 29 日晚 9 点 4 月 1 日上课

OOP with Java 通知 Project 3: 3 月 29 日晚 9 点 4 月 1 日上课 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 3: 3 月 29 日晚 9 点 4 月 1 日上课 复习 Java 包 创建包 : package 语句, 包结构与目录结构一致 使用包 : import restaurant/ - people/ - Cook.class - Waiter.class - tools/ - Fork.class

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

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

C++ 程序设计 实验 2 - 参考答案 MASTER 2017 年 5 月 21 日 1

C++ 程序设计 实验 2 - 参考答案 MASTER 2017 年 5 月 21 日 1 C++ 程序设计 实验 2 - 参考答案 MASTER 2017 年 5 月 21 日 1 1 CRECT 类 1 CRect 类 设计矩形类, 包含 长度和宽度信息 基本构造函数 基础属性的访问接口 ( 读 / 写, Read/Write, Get/Set) 计算周长和面积 ( 注 : 基本构造函数, 一个无参数的默认构造函数, 以及一个初始化数据成员的构造函数如果数据成员的初始化有多种形式, 就提供多个构造函数

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 点 复习 Java 包 创建包 : package 语句, 包结构与目录结构一致 使用包 : import restaurant/ - people/ - Cook.class - Waiter.class - tools/ - Fork.class - Table.class

More information

Microsoft PowerPoint - 3. 函数Functionl.ppt [兼容模式]

Microsoft PowerPoint - 3. 函数Functionl.ppt [兼容模式] 函数 Function 如何重用代码 How to reuse code 3 4 = 3*3*3*3 3 4,6 5 : 拷贝 - 粘帖代码 (Copy-paste code) 3 4,6 5,12 10 : 拷贝 - 粘帖代码 (Copy-paste code) Bad! 使用函数 (with a function) 使用函数 (with a function) 使用函数 (with a function)

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

Chapter 9: Objects and Classes

Chapter 9: Objects and Classes Fortran Algol Pascal Modula-2 BCPL C Simula SmallTalk C++ Ada Java C# C Fortran 5.1 message A B 5.2 1 class Vehicle subclass Car object mycar public class Vehicle extends Object{ public int WheelNum

More information

Microsoft Word - chap10.doc

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

More information

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

Microsoft Word - 新1-12.doc

Microsoft Word - 新1-12.doc 实训 5 面向对象编程练习 实训 5 面向对象编程练习 5.1 实训目的 通过编程和上机实验理解 Java 语言是如何体现面向对象编程基本思想 以及如何创建类 和对象 了解成员变量和成员方法的特性 5.2 实训要求 编写一个体现面向对象思想的程序 编写一个创建对象和使用对象的方法的程序 5.3 实训内容 5.3.1 创建对象并使用对象 1 定义一个 Person 类 可以在应用程序中使用该类 成员属性

More information

<4D6963726F736F667420506F776572506F696E74202D20332D322E432B2BC3E6CFF2B6D4CFF3B3CCD0F2C9E8BCC6A1AAD6D8D4D8A1A2BCCCB3D0A1A2B6E0CCACBACDBEDBBACF2E707074>

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

More information

FY.DOC

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

More information

第七讲 继承与多态

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

More information

OOP with Java 通知 Project 3 提交时间 3 月 29 日晚 9 点 Piazza Project 2 投票

OOP with Java 通知 Project 3 提交时间 3 月 29 日晚 9 点 Piazza Project 2 投票 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 3 提交时间 3 月 29 日晚 9 点 Piazza Project 2 投票 复习 创建对象 构造函数 函数重载 : 函数 = 函数名 + 参数列表 public class MyType { int i; double d; char c; void set(double x)

More information

软件工程文档编制

软件工程文档编制 实训抽象类 一 实训目标 掌握抽象类的定义 使用 掌握运行时多态 二 知识点 抽象类的语法格式如下 : public abstract class ClassName abstract void 方法名称 ( 参数 ); // 非抽象方法的实现代码 在使用抽象类时需要注意如下几点 : 1 抽象类不能被实例化, 实例化的工作应该交由它的子类来完成 2 抽象方法必须由子类来进行重写 3 只要包含一个抽象方法的抽象类,

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

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

新版 明解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

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

山东建筑大学学分制管理规定(试行)

山东建筑大学学分制管理规定(试行) 山 建 大 校 字 2015 67 号 山 东 建 筑 大 学 关 于 印 发 学 分 制 管 理 规 定 ( 试 行 ) 的 通 知 各 院 部 校 直 各 部 门 : 山 东 建 筑 大 学 学 分 制 管 理 规 定 ( 试 行 ) 已 经 学 校 研 究 同 意, 现 印 发 给 你 们, 请 认 真 遵 照 执 行 山 东 建 筑 大 学 2015 年 8 月 7 日 1 山 东 建 筑

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

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

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

提问袁小兵:

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

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

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

1.5招募说明书(草案)

1.5招募说明书(草案) PUBLIC 2014 1 PUBLIC - 1 2014 1 PUBLIC - 2 2014 1 PUBLIC - 3 2014 1 PUBLIC - 4 2014 1 PUBLIC - 5 2014 1 PUBLIC - 6 2014 1 PUBLIC - 7 2014 1 PUBLIC - 8 2014 1 PUBLIC - 9 2014 1 PUBLIC - 10 2014 1 PUBLIC

More information

C++ 程序设计 OJ4 - 参考答案 MASTER 2019 年 5 月 30 日 1

C++ 程序设计 OJ4 - 参考答案 MASTER 2019 年 5 月 30 日 1 C++ 程序设计 OJ4 - 参考答案 MASTER 2019 年 月 30 日 1 1 STRINGSORT 1 StringSort 题目描述 编写程序, 利用 string 类完成一个字符串中字符的排序 ( 降序 ) 并输出 输入描述 输入仅一行, 是一个仅由大小写字母和数字组成的字符串 输出描述 输出排序后的字符串 样例输入 abcde 样例输出 edcba 提示 使用 std::sort

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

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

Microsoft Word - 970617cppFinalSolution.doc

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

More information

KillTest 质量更高 服务更好 学习资料 半年免费更新服务

KillTest 质量更高 服务更好 学习资料   半年免费更新服务 KillTest 质量更高 服务更好 学习资料 http://www.killtest.cn 半年免费更新服务 Exam : 310-055Big5 Title : Sun Certified Programmer for the Java 2 Platform.SE 5.0 Version : Demo 1 / 22 1. 11. public static void parse(string str)

More information

Chapter 1 What is Programing Paradigm 1

Chapter 1 What is Programing Paradigm 1 An Introduction to Programing Paradigm Chase Zhang May 8, 2013 Chapter 1 What is Programing Paradigm 1 CHAPTER 1. WHAT IS PROGRAMING PARADIGM 2 Definition from Wikipedia 1. Object-oriented programming/

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

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 Word - 第7章 类与对象.docx

Microsoft Word - 第7章 类与对象.docx 第 7 章类与对象 案例 1 地址类 #include class Address char Name[21]; char Street[51]; char City[51]; char Postcode[10]; SetAddress(char *name,char *street,char *city,char *postcode); void ChangeName(char

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

Microsoft PowerPoint - plan08.ppt

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

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 付 款 資 料 信 用 卡 別 信 用 卡 號 信 用 卡 有 效 日 期 3 住 房 條 件 入 住 日 期 退 房 日 期 人 數 房 間 數 量 入

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

More information

Microsoft PowerPoint - 07 派生数据类型

Microsoft PowerPoint - 07 派生数据类型 能源与动力工程学院 目录 派生类型 陈 斌 固有数据类型 数值型 (numerical) 整型 INTEGER 实型 REAL 复数型 COMPLEX 非数值型 字符型 CHARACTER 逻辑型 ( 布尔型 )LOGICAL 自定义数据类型 ( 派生类型, derived type) 派生类型是指用户利用 Fortran 系统内部类型, 如整型 实型 复数型 逻辑型 字符型等的组合自行创建出一个新的数据类型,

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

Factory Methods

Factory Methods Factory Methods 工 厂 方 法 eryar@163.com 摘 要 Abstract: 本 文 主 要 是 对 API Design for C++ 中 Factory Methods 章 节 的 翻 译, 若 有 不 当 之 处, 欢 迎 指 正 关 键 字 Key Words:C++ Factory Pattern 一 概 述 Overview 工 厂 方 法 是 创 建 型 模

More information

使 用 Java 语 言 模 拟 保 险 箱 容 量 门 板 厚 度 箱 体 厚 度 属 性 锁 具 类 型 开 保 险 箱 关 保 险 箱 动 作 存 取 款

使 用 Java 语 言 模 拟 保 险 箱 容 量 门 板 厚 度 箱 体 厚 度 属 性 锁 具 类 型 开 保 险 箱 关 保 险 箱 动 作 存 取 款 JAVA 程 序 设 计 ( 肆 ) 徐 东 / 数 学 系 使 用 Java 语 言 模 拟 保 险 箱 容 量 门 板 厚 度 箱 体 厚 度 属 性 锁 具 类 型 开 保 险 箱 关 保 险 箱 动 作 存 取 款 使 用 Java class 代 表 保 险 箱 public class SaveBox 类 名 类 类 体 实 现 封 装 性 使 用 class SaveBox 代 表 保

More information

OOP with Java 通知 Project 2 提交时间 : 3 月 14 日晚 9 点 另一名助教 : 王桢 学习使用文本编辑器 学习使用 cmd: Power shell 阅读参考资料

OOP with Java 通知 Project 2 提交时间 : 3 月 14 日晚 9 点 另一名助教 : 王桢   学习使用文本编辑器 学习使用 cmd: Power shell 阅读参考资料 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 2 提交时间 : 3 月 14 日晚 9 点 另一名助教 : 王桢 Email: 51141201063@ecnu.cn 学习使用文本编辑器 学习使用 cmd: Power shell 阅读参考资料 OOP with Java Java 类型 引用 不可变类型 对象存储位置 作用域 OOP

More information

程序设计语言及基础

程序设计语言及基础 Chapter 10 Classes: A Deeper Look, Part 2 http://jssec.seu.edu.cn 杨明 yangming2002@seu.edu.cn OBJECTIVES To specify const (constant) objects and const member functions. To create objects composed of other

More information

C++ 程序设计 OJ9 - 参考答案 MASTER 2019 年 6 月 7 日 1

C++ 程序设计 OJ9 - 参考答案 MASTER 2019 年 6 月 7 日 1 C++ 程序设计 OJ9 - 参考答案 MASTER 2019 年 6 月 7 日 1 1 CARDGAME 1 CardGame 题目描述 桌上有一叠牌, 从第一张牌 ( 即位于顶面的牌 ) 开始从上往下依次编号为 1~n 当至少还剩两张牌时进行以下操作 : 把第一张牌扔掉, 然后把新的第一张放到整叠牌的最后 请模拟这个过程, 依次输出每次扔掉的牌以及最后剩下的牌的编号 输入 输入正整数 n(n

More information

ebook55-13

ebook55-13 1 3 C + + C C + + 13.1 X 256 C + + p r i v a t e p u b l i c p e r m u t e () X X Y 13.2 Y Y X 13 257 Y X Y X X m a i n () s i z e o f ( Y s i z e o f ( X ) p u b l i c p r i v a t e p u b l i c p r i

More information

本章学习目标 小风 Java 实战系列教程 SpringMVC 简介 SpringMVC 的入门案例 SpringMVC 流程分析 配置注解映射器和适配器 注解的使用 使用不同方式的跳转页面 1. SpringMVC 简介 Spring web mvc

本章学习目标 小风 Java 实战系列教程 SpringMVC 简介 SpringMVC 的入门案例 SpringMVC 流程分析 配置注解映射器和适配器 注解的使用 使用不同方式的跳转页面 1. SpringMVC 简介 Spring web mvc 本章学习目标 SpringMVC 简介 SpringMVC 的入门案例 SpringMVC 流程分析 配置注解映射器和适配器 配置视图解析器 @RequestMapping 注解的使用 使用不同方式的跳转页面 1. SpringMVC 简介 Spring web mvc 和 Struts2 都属于表现层的框架, 它是 Spring 框架的一部分, 我们可 以从 Spring 的整体结构中看得出来 :

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

Microsoft PowerPoint - 4. 数组和字符串Arrays and Strings.ppt [兼容模式]

Microsoft PowerPoint - 4. 数组和字符串Arrays and Strings.ppt [兼容模式] Arrays and Strings 存储同类型的多个元素 Store multi elements of the same type 数组 (array) 存储固定数目的同类型元素 如整型数组存储的是一组整数, 字符数组存储的是一组字符 数组的大小称为数组的尺度 (dimension). 定义格式 : type arrayname[dimension]; 如声明 4 个元素的整型数组 :intarr[4];

More information

OOP with Java 通知 Project 4: 推迟至 4 月 25 日晚 9 点

OOP with Java 通知 Project 4: 推迟至 4 月 25 日晚 9 点 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 4: 推迟至 4 月 25 日晚 9 点 复习 Protected 可以被子类 / 同一包中的类访问, 不能被其他类访问 弱化的 private 同时赋予 package access class MyType { public int i; public double d; public

More information

1 1 大概思路 创建 WebAPI 创建 CrossMainController 并编写 Nuget 安装 microsoft.aspnet.webapi.cors 跨域设置路由 编写 Jquery EasyUI 界面 运行效果 2 创建 WebAPI 创建 WebAPI, 新建 -> 项目 ->

1 1 大概思路 创建 WebAPI 创建 CrossMainController 并编写 Nuget 安装 microsoft.aspnet.webapi.cors 跨域设置路由 编写 Jquery EasyUI 界面 运行效果 2 创建 WebAPI 创建 WebAPI, 新建 -> 项目 -> 目录 1 大概思路... 1 2 创建 WebAPI... 1 3 创建 CrossMainController 并编写... 1 4 Nuget 安装 microsoft.aspnet.webapi.cors... 4 5 跨域设置路由... 4 6 编写 Jquery EasyUI 界面... 5 7 运行效果... 7 8 总结... 7 1 1 大概思路 创建 WebAPI 创建 CrossMainController

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

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

幻灯片 1

幻灯片 1 第三课类和对象 ( 封装 ) 互联网新技术在线教育领航者 1 内容概述 1. 封装的概念 2. 访问控制 3. 栈类的封装 4. 构造与析构 5.myString 构造函数 6. 构造与析构的次序 7. 类文件写法 8. 对象的内存 9.this 指针初探 10. 构造函数初始值列表 11. 拷贝构造和赋值运算符重载 12. 浅拷贝 13. 深拷贝 14. 成员函数内联 15. 友元 16.const

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

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 点 复习 Protected 可以被子类 / 同一包中的类访问, 不能被其他类访问 弱化的 private 同时赋予 package access class MyType { public int i; public double d; public char

More information

Microsoft PowerPoint - 04-Inheritance.ppt

Microsoft PowerPoint - 04-Inheritance.ppt 继承 派生与多态性 1 本章主要内容 类的继承与派生 类成员的访问控制 简单继承与多重继承 派生类的构造 析构函数 多态性 2 1 类的继承与派生 保持已有类的特性, 并在其基础上产生新的类, 称新类继承了已有类的特征, 或称已有类派生出新类 被继承的已有类称为基类 ( 或父类 ) 派生出的新类称为派生类 派生类将自动继承基类的所有特性 ( 属性和方法 ) 派生类可以定义新的特性 ( 属性和方法 )

More information

绘制OpenCascade中的曲线

绘制OpenCascade中的曲线 在 OpenSceneGraph 中绘制 OpenCascade 的曲线 Draw OpenCascade Geometry Curves in OpenSceneGraph eryar@163.com 摘要 Abstract: 本文简要说明 OpenCascade 中几何曲线的数据, 并将这些几何曲线在 OpenSceneGraph 中绘制出来 关键字 KeyWords:OpenCascade Geometry

More information

<4D F736F F F696E74202D20B5DA3032BDB25FC0E0BACDB6D4CFF3312E BBCE6C8DDC4A3CABD5D>

<4D F736F F F696E74202D20B5DA3032BDB25FC0E0BACDB6D4CFF3312E BBCE6C8DDC4A3CABD5D> 程序设计实习 (I): C++ 程序设计 第二讲类和对象 (1) 面向对象的程序设计 面向对象的程序设计方法, 能够较好解决结构化程序设计中出现的问题 面向对象的程序 = 类 + 类 + + 类 设计程序的过程, 就是设计类的过程 2 面向对象的程序设计 面向对象的程序设计方法 : 将某类客观事物共同特点 ( 属性 ) 归纳出来, 形成一个数据结 构 ( 可以用多个变量描述事物的属性 ); 将这类事物所能进行的行为也归纳出来,

More information

Microsoft Word - well_game.doc

Microsoft Word - well_game.doc 智慧型系統控制 趙春棠老師 四技機電四甲 49422019 黃秉宏 井字遊戲並沒有什麼必勝的著法, 但只要適當的回應, 就可保持不敗 也 1 2 3 4 5 6 7 8 9 法則 手玩家的最佳著法其第一步最好下在四個角落 ( 即 2 4 6 8 號位置 ), 因為後手玩家除了下在中央的 5 號位置之外必敗 即使對手下了該位置, 只要回以馬步佈局或對角佈局也還有一半的勝算 先手玩家第一步的次佳選擇在

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

!"#$ % & ())*$ $ +,-./0)1)1/.21/.$ 3 4$ 5 4$ 6 789:;9< $ = :; A B CD ())* E )FG(*? H$ $ $ $ $ $ $ $ $ $ % IJ!"#% &$ KLMNO 2(* H 2G))(2 $ PQ R

!#$ % & ())*$ $ +,-./0)1)1/.21/.$ 3 4$ 5 4$ 6 789:;9< $ = :; A B CD ())* E )FG(*? H$ $ $ $ $ $ $ $ $ $ % IJ!#% &$ KLMNO 2(* H 2G))(2 $ PQ R !"#$ % & ())*$ $ +,-./0)1)1/.21/.$ 3 4$ 5 4$ 6 789:;9< $ = >?((@0$ :; A B CD ())* E )FG(*? H$ $ $ $ $ $ $ $ $ $ % IJ!"#% &$ KLMNO 2(* H 2G))(2 $ PQ R STU$ VW ;XY Z [$ \] ^_ a\]b$ c ())* d G ee 2 $ H +,-./0)1)1/.21/.

More information

SDK 概要 使用 Maven 的用户可以从 Maven 库中搜索 "odps-sdk" 获取不同版本的 Java SDK: 包名 odps-sdk-core odps-sdk-commons odps-sdk-udf odps-sdk-mapred odps-sdk-graph 描述 ODPS 基

SDK 概要 使用 Maven 的用户可以从 Maven 库中搜索 odps-sdk 获取不同版本的 Java SDK: 包名 odps-sdk-core odps-sdk-commons odps-sdk-udf odps-sdk-mapred odps-sdk-graph 描述 ODPS 基 开放数据处理服务 ODPS SDK SDK 概要 使用 Maven 的用户可以从 Maven 库中搜索 "odps-sdk" 获取不同版本的 Java SDK: 包名 odps-sdk-core odps-sdk-commons odps-sdk-udf odps-sdk-mapred odps-sdk-graph 描述 ODPS 基础功能的主体接口, 搜索关键词 "odpssdk-core" 一些

More information

运算符重载 为什么要 运算符重载 那些运算符可以重载, 哪些不可以 如何实现运算符重载 实现方式 : 成员函数与非成员函数 类型转换 怎样实现对象与基本数据类型数据的运算 2

运算符重载 为什么要 运算符重载 那些运算符可以重载, 哪些不可以 如何实现运算符重载 实现方式 : 成员函数与非成员函数 类型转换 怎样实现对象与基本数据类型数据的运算 2 第十一讲 运算符重载 与类型转换 运算符重载 为什么要 运算符重载 那些运算符可以重载, 哪些不可以 如何实现运算符重载 实现方式 : 成员函数与非成员函数 类型转换 怎样实现对象与基本数据类型数据的运算 2 为什么要运算符重载 预定义的运算符只针对基本数据类型, 若要对类的对象进行类似的运算, 需要重新定义运算符的功能 运算符重载实质就是函数重载 : 对已有的运算符赋予多重含义, 使得同一个运算符作用于不同类型的数据时导致不同的行为

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 点 复习 Protected 可以被子类 / 同一包中的类访问, 不能被其他类访问 弱化的 private 同时赋予 package access class MyType { public int i; public double d; public char

More information

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

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

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

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

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

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

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

Volume 2.Number 5.2007 Volume 2.Number 5.2007 Volume 2.Number 5.2007 Volume 2.Number 5.2007 Volume 2.Number 5.2007 Volume 2.Number 5.2007 Volume 2.Number 5.2007 Volume 2.Number 5.2007 Volume 2.Number

More information

说 : 荀 子 极 偏 驳, 只 一 句 性 恶, 大 本 已 失 5 朱 熹 说 : 荀 扬 不 惟 说 性 不 是, 从 头 到 底 皆 不 识 6 采 取 的 都 是 这 种 理 论 框 架 另 一 种 理 论 框 架 始 于 20 世 纪 前 期, 这 便 是 诸 子 学 研 究 的 框 架

说 : 荀 子 极 偏 驳, 只 一 句 性 恶, 大 本 已 失 5 朱 熹 说 : 荀 扬 不 惟 说 性 不 是, 从 头 到 底 皆 不 识 6 采 取 的 都 是 这 种 理 论 框 架 另 一 种 理 论 框 架 始 于 20 世 纪 前 期, 这 便 是 诸 子 学 研 究 的 框 架 第 一 章 绪 论 1. 问 题 与 文 献 本 文 试 图 探 讨 的 核 心 问 题, 一 言 以 蔽 之, 是 要 理 解 并 诠 释 荀 子 思 想 的 基 本 性 格 先 交 代 研 究 方 法 迄 今 为 止 的 荀 学 研 究 1 大 致 存 在 两 种 研 究 框 架 第 一 种 研 究 框 架 是 理 学 研 究 的 理 论 框 架 2, 该 框 架 主 张 以 孔 孟 作 为 研

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

ASP.NET实现下拉框二级联动组件

ASP.NET实现下拉框二级联动组件 ASP.NET 实现下拉框二级联动组件 namespace WebApplicationDlh using System.Drawing; using System.Web; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using Db; / / Area 的摘要说明 /

More information

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

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

More information

《C语言程序设计》教材习题参考答案

《C语言程序设计》教材习题参考答案 教材名称 : C 语言程序设计 ( 第 1 版 ) 黄保和 江弋编著清华大学出版社 ISBN:978-7-302-13599-9, 红色封面 答案制作时间 :2011 年 2 月 -5 月 一 选择题 1. 设已定义 int a, * p, 下列赋值表达式中正确的是 :C)p=&a 2. 设已定义 int x,*p=&x;, 则下列表达式中错误的是 :B)&*x 3. 若已定义 int a=1,*b=&a;,

More information

Microsoft PowerPoint - 7. 面向对象程序设计-Object-Oriented Programming.ppt [兼容模式]

Microsoft PowerPoint - 7. 面向对象程序设计-Object-Oriented Programming.ppt [兼容模式] 面向对象程序设计 Object-Oriented Programming(OOP) Classes,Inheritance, Polymorphism A Survey of Programming Techniques Unstructured programming, procedural programming, modular programming and object-oriented

More information

提纲 1 2 OS Examples for 3

提纲 1 2 OS Examples for 3 第 4 章 Threads2( 线程 2) 中国科学技术大学计算机学院 October 28, 2009 提纲 1 2 OS Examples for 3 Outline 1 2 OS Examples for 3 Windows XP Threads I An Windows XP application runs as a seperate process, and each process may

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

Microsoft PowerPoint - 5. 指针Pointers.ppt [兼容模式]

Microsoft PowerPoint - 5. 指针Pointers.ppt [兼容模式] 指针 Pointers 变量指针与指针变量 Pointer of a variable 变量与内存 (Variables and Memory) 当你声明一个变量时, 计算机将给该变量一个内存, 可以存储变量的值 当你使用变量时, 计算机将做两步操作 : - 根据变量名查找其对应的地址 ; - 通过地址对该地址的变量内容进行读 (retrieve) 或写 (set) 变量的地址称为变量的指针! C++

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

《计算概论》课程 第十九讲 C 程序设计语言应用

《计算概论》课程 第十九讲  C 程序设计语言应用 计算概论 A 程序设计部分 字符数组与字符串 李戈 北京大学信息科学技术学院软件研究所 lige@sei.pku.edu.cn 字符数组的定义 #include int main() char a[10] = 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' ; for (int i = 0; i < 10; i++) cout

More information

슬라이드 1

슬라이드 1 2018-2019 年度第二学期 00106501 计算机图形学 童伟华管理科研楼 1205 室 E-mail: tongwh@ustc.edu.cn 中国科学技术大学数学科学学院 http://math.ustc.edu.cn/ 附讲三 C/C++ 编程 ( 二 ) 2 C++ 特点 C++ 是面对对象 (object oriented) 编程语言 纯面向对象语言 : 指不管什么东西, 都应该存在于对象之中,

More information