1.4 面向对象的基本概念
類:CLass
對象:Object
類和對象的關系:先有雞還是先有蛋
用對象來定義類,用類產生對象
在設計軟件的時候,對象是不存在的
軟件系統運行時,在內存中創建對象,類不存在于物理世界。
what is a Class、Object?
A class is a description of a set of of objects that share the same attributes , operations,relationships and semantics
對象是描述共享一組相同屬性、操作、關系和行為的符。
An Object is an Instance created? from a class
對象是根據類創建的一個實例
An inatance's behaviour and information structure is defined in the class 實例的行為和信息結構是被類定義的
It's current state(values of instance variables) is defined by operations performed on it.對象當前的狀態(實例變量的值)取決于作用于該對象的操作
軟件的功能是如何完成的?
類
定義了對象群體的邏輯結構,包括屬性和操作
系統運行時,類作為產生對象的模板,在物理層面是不存在的
對象
系統運行時必須為每一個需要的對象分配內存、保存數據
對象存在于物理層面,每個對象都有自己的數據空間(內存)
所有的對象共用同一塊代碼空間
消息
對象之間的一種交流手段
所有相關對象之間相互協作完成軟件功能
類和對象小結
Everything is an object 每一樣東西都是對象
A program is a bunch of objects telling each other what to do by sending messages 一個程序就是有一大群對象相互間通過發送消息告訴對方該做什么
each object has its own memory made up of other objects 每個對象都有自己的內存空間,里面存放了許多其他的對象
every object has a type
each object is an instace of a class,in which "class" is synoymous with "type"
all objects of a perticular type can receive the same messages
轉載于:https://www.cnblogs.com/mayZhou/p/10293936.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的1.4 面向对象的基本概念的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: docker安装教程-centos
- 下一篇: 创建型模式:抽象工厂