PDA

View Full Version : Inheritance and Composition vs public protected and private ในภาษาซี



fftmj
17-02-2010, 02:16 PM
Class A{};

Class D_public : public A{} // Inheritance
Class D_protected : protected A{} // Inheritance
Class D_private : private A{} // Inheritance
Class D_compos { A a;}

อืม .... ถ้า คลาส A เป็น เบส แล้ว ให้ถูก derive class มาเป็น คลาส D ซึ่งมีทั้ง 4 กรณี
โดยถูก Derive ด้วยวิธีการที่แตกต่างกัน จะทำให้การเข้าถึง ตัวแปร และ เมเธอ ของคลาส D
ทั้ง 4 มีความแตกต่างกัน ด้วย


????
**Hidden Content: Check the thread to see hidden data.**