面向对象与图形编程
数据与操作:传统观点 数据类型(data type) Each data type can represent a certain set of values(某种值的集合) each had a set of associated operations(运算,操 作) The traditional programming view is that data is passive(被动的),-it's manipulated and combined with active(主动的)operations. 例如:string类型的值是'abc'等,对串的操作有+,*,len()等 2
2
数据与操作:面向对象观点 对象(Object) An object is a sort of active data type that combines data and operations. -对象contain data. - 对象have operations. view a complex system as the interaction of simpler objects.Objects interact by sending each other messages. 3
3
数据与操作:面向对象观点 面向对象(Object-Oriented基本思想: 软件系统由各种对象组成,对象之间通过消息进行交 互. 00语言 C++(过程性语言C发展而来) Visual Basic(过程性语言Basic发展而来) Java Python 4
4
OO基本概念 类(class):描述同类对象的共性 包含的数据 ·任何类型的数据,甚至可以是对其他对象的引用. -1 能执行的操作(方法) 对象(object):类的实例(instance) 一类可以创建多个实例 同类的不同对象可有不同的数据值(实例变量),但能执行的 操作是一样的 例如: 类:file 对象:infileName,outfileName 5
5