提示: 作者被禁止或刪除 內容自動屏蔽

TOP

樓主又問Pascal又問OOP, 岩岩開始學校Programming Course?

TOP

本帖最後由 ghostkcleung 於 2022-5-25 06:01 編輯

一切由呢度開始,之後有興趣嘅話,再追落去。
學 OOP 嘅話,我依然係堅持用 C++ 嚟學。

// hello_point.cpp
#include<iostream>
using namespace std;

class Point {
   public:
     int x = 0;      // This is attribute
     int y = 0;     // This is attribute

     /*** This is method ***/
     void show ( ) {
        cout << "Hello, x=" << x << ", y = " << y << endl;
     }
}

int main ( ) {
   Point *p = new Point ( ) ; // Create object
   p -> x = 15;
   p -> y = 25;

   p -> show ( ) ; // Take action
   // Output: Hello, x=15, y=25

   delete p ;          // Free memory
}

TOP

oop is a way of thinking, it is easier to maintain and expend your lib. for example, if you have some code of moving a people in a video game, you can add some code for moving a horse by making both people and horse as "movable object", therefore a "move" command for any "movable object" will take care of itself. almost every language can be object oriented, even assembly,
https://www.amazon.com/Object-Or ... rfman/dp/0830676201
that is a very interesting book.

TOP

object.method()

carmansze 發表於 2022-5-14 11:28

TOP

好多人而家寫 OO 寫到同 Sequential 無分別

TOP

oop是一種編程方針,一些語言本身有oop語法,你唔用就唔係oop,一些語言本身無oop,你照用(例如用array來達到properties同method效果),咁都係oop。
‘object’唔係單指button之類的visible東西,佢可以係一個folder,一個table。簡單D講,一般programming我哋有variable。但variable只有value. 但object可以有value以外的東西,例如颜色,字型,Excel workbook嘅cell, 或都係自已的method,例如一個Excel workbook嘅object有SaveAs()呢D method。
希望幫到ching初步明白oop.

via HKEPC Reader for Android

TOP

唔認同。
學java  oop 不用識pointer, 雖然成日null pointer exception

唔認同。

學 OOP 之前,要識 Pointer,同埋 Struct,
最好識埋 Data Structure ,
我認為 C++ 一定係首選 ...
ghostkcleung 發表於 2022-5-17 14:07

TOP