By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ ....
Transcript of By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ ....
![Page 2: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/2.jpg)
การพฒนาระบบงานทางคอมพวเตอรดวยวธการ
ของเทคโนโลยเชงวตถ การสรางชนดขอมล คลาส
คณสมบตของวตถ การรบทอด การหอหม โพลมอรฟซม
การวเคราะหและการออกแบบระบบงานเชงวตถ API
(Application Programming Interface) ของภาษาท
ใช ในการเขยนโปรแกรมเชงวตถ และการพฒนา
โครงงานเชงวตถ
![Page 3: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/3.jpg)
สงกอนสอบ / สป. สดทายของการเรยนการสอน
พฒนาระบบงานดานเชงวตถ ดวยภาษา จาวา โดย
ใชโปรแกรม netbean IDE
ประกอบไปดวย
◦ ตวโปรแกรม / Source Code
◦ เอกสารประกอบโปรแกรม / รปเลมรายงาน
![Page 4: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/4.jpg)
![Page 5: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/5.jpg)
การเขยนโปรแกรมคอมพวเตอรม 2 แบบ
◦ การเขยนโปรแกรมแบบโครงสราง
◦ การเขยนโปรแกรมเชงวตถ
![Page 6: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/6.jpg)
ภาษาเชงวตถนไดเรมมมาตงแตกอนป ค.ศ. 1960 และภาษาทเปนตนแบบในขณะนนคอ ภาษา Simula ทใชเปนหลกการของ Object ในการสรางโปรแกรม ทาใหระบบในการเขยนโปรแกรมมลกษณะทเขาใกลกบความคดมนษยในโลกความเปนจรงมากขน ตอมาภาษา Smalltalk กไดรบการพฒนาเขามาแทนท Simula
![Page 7: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/7.jpg)
ในป 1967 ภาษา Simula67 ถกพฒนาทนอรเวย เพอชวยในการเขยนโปรแกรมสาหรบจาลอง (Simulation)
โดยทวไประบบทซบซอนจะประกอบดวยวตถจานวนมากททางานเกยวของกน โดยการสรางโปรแกรมทจาลองการทางานของแตละวตถไปทละขนจนกวาจะไดคาตอบซงแนวคดนเรยกวา การโปรแกรมเชงวตถ
1990s มภาษาเกาถกเพมเตมในสวนของการโปรแกรมเชงวตถ แตโดยพนฐานของภาษาจงทาใหกลไกไมเปนเชงวตถอยางสมบรณ
![Page 8: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/8.jpg)
การเขยนโปรแกรมแบบโครงสราง คอ การเขยนคาสงเรยงตอกนไปเรอยๆ ทละ
บรรทด โปรแกรมจะเรมทางานจากคาสงแรกสดเรอยไปจนถงคาสงทายสด เปนอน
จบโปรแกรม อาจมการสรางเปนโปรแกรมยอยๆ ในโปรแกรมใหญบาง เพอลดคาสง
ทซ าซอน
ตวอยางเชน ภาษาเบสก ภาษาโคบอล ภาษาฟอรแทรน ภาษาปาสคาล และ ภาษาซ
![Page 9: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/9.jpg)
การเขยนโปรแกรมเชงวตถ คอ การสรางวตถสมมตขนมากอน แลวเขยนคาสงนยาม
วตถนนจนสามารถทาใหวตถนนทางานตามทตองการได
ซอรสโคดของโปรแกรมเชงวตถแทนทจะเปนคาสงเขยนเรยงตอกนไปเรอยๆ จะเปน
นยามของวตถเขยนเรยงตอไปเรอยๆ แทนและโปรแกรมจะทางานไดเองถาวตถนน
ถกนยามขนอยางเหมาะสม
ตวอยางเชน ภาษาจาวา และภาษาซพลสพลส (ภาษาซพลสพลสเขยนไดทงแบบ
โครงสรางและวตถ)
![Page 10: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/10.jpg)
การเขยนโปรแกรมเชงวตถตองใชเวลาในการศกษานานพอสมควร โดยเฉพาะอยางยง
นกเขยนโปรแกรมตองมความชานาญในการสรางวตถสมมตททางานตามอยางทเรา
ตองการได
โปรแกรมประยกตทใชงานจรงในปจจบนลวนแลวแตเขยนดวยโปรแกรมเชงวตถ
ทงสน
การศกษาการเขยนโปรแกรมเชงวตถจงเปนสงทนกเขยนโปรแกรมรนใหมทกคนควร
จะฝกฝนไว
![Page 11: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/11.jpg)
ขอด : มความกะทดรด
ขอเสย : ตองใชเวลาศกษานาน โดยเฉพาะอยางยงคนทไมใชนกเขยนโปรแกรมมอ
อาชพ เพราะการเขยนโปรแกรมเชงวตถ ไมใชเรองทจะเรยนรไดในเวลาอนรวดเรว
![Page 12: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/12.jpg)
![Page 13: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/13.jpg)
การเนนทปญหาและองคประกอบของปญหาเพอการแกปญหานน เรยกวา Problem
space
เหมอนการจาลองความเปนจรงในชวตความเปนอยของมนษยทจะประกอบดวย คน
สตว สงของ และใชสงตางๆ เพอแกปญหา คอ แตละสง มหนาทในการแกปญหา
![Page 14: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/14.jpg)
Problem Space
หญาในสนามรก
คนตดหญา >> ตดหญา ใชเครองตดหญา
เครองตดหญา >> ตดหญา ทาใหหญาทสงถกตด
![Page 15: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/15.jpg)
ป�ญหา
(Problem)
กาหนดขนตอน
การแกป�ญหาSolution Space
กาหนดป�ญหาเป�น
องคประกอบProblem Space
การเขยนโปรแกรม
แบบโปรซเยอร
การเขยนโปรแกรม
เชงวตถ
![Page 16: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/16.jpg)
ปญหาการหาพนทรปสเหลยมผนผาใดๆ
◦ สามารถหาพนทสเหลยมผนผาโดยใชสตร
พนทสเหลยม = กวาง x ยาว
◦ ดงนน ตองทราบ ความกวาง และ ความยาว ของสเหลยมเสยกอน
รบขอมล
(ความกวางและความยาว
ของสเหลยม)
แสดงพนทสเหลยม
ออกทางหนาจอ
คานวณ
พนทสเหลยม = กวาง x ยาว
ขนตอนการหาพนทรปสเหลยมผนผา
![Page 17: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/17.jpg)
1. ในระบบนจะตองประกอบดวยวตถทจาเปนใดบาง
- หาวตถทเกยวของ เชน สเหลยม ความกวาง ความยาวและพนท
- ตดวตถทมลกษณะเหมอนกนออก
- วเคราะหลกษณะของแตละวตถ เชน สเหลยมควรมสวนประกอบ
เปนตาแหนง ความกวาง ความยาว และพนท เปนตน ดงนนเราสามารถ
รวม พนท ความกวางและความยาว เปนของสเหลยม
- วเคราะหพฤตกรรมของแตละวตถ ตอนนมวตถเดยวสเหลยม
อาจจะตอง คานวณเสนรอบรป คานวณพนท วาดตวเอง เปนตน
![Page 18: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/18.jpg)
วตถสเหลยมผนผา
ความกวาง
ความยาว
พนท
![Page 19: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/19.jpg)
พฤตกรรม
◦ คานวณความยาวเสนรอบรป
◦ คานวณพนท
◦ วาดตวเอง
ตอนนทราบวาจะมวตถใดอยในระบบบาง ขนตอนตอมา คอ ตองหาความสมพนธ
ของแตละวตถ แตในทนมวตถเดยวจงไมตองทา
![Page 20: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/20.jpg)
![Page 21: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/21.jpg)
โดยทมผคนมากมายทเชอวา Smalltalk คอภาษาเชงวตถ Programming อยางแทจรง ตอมาภาษา C++ กไดเกดขน ดวยหลกการเชงวตถเชนกน ภาษา C++ เปนภาษาทไดรบความนยมคอนขางมาก มการนาไปใชงานอยางกวางขวางในวงการตางๆ แตปจจบนภาษา java ไดเขามามบทบาทมากขนและเหมอนวาจะเขามาแทนท C++ ในไมชา ดวยความสามารถหลายๆ อยางของภาษา java ทสามารถลดขอเสยของ C++ ได
โปรแกรมภาษาเชงวตถ (Object-Oriented Programming Language : OOPL)
![Page 22: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/22.jpg)
Object Orientation หมายถง การใช Object เปนตว
หลกเพอการพจารณาความเปนจรงตางๆ ทเกดขนในโลก
ดวยการมองทกๆ สงในโลกใหเปนวตถทงหมด และมองวา
กจกรรมทงหมดทเกดขนในโลกนเกดจากความสมพนธและ
ปฏสมพนธระหวางวตถ
![Page 23: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/23.jpg)
การมองทกสงในโลกใหเปนวตถ เปนการทาใหปญหาทเปน
นามธรรม (Abstraction) กลายมาเปนรปธรรม เพอทาให
คอมพวเตอรสามารถแกปญหาเหลานนไดดวยการพฒนาเปน
ซอฟตแวร และการพฒนาซอฟตแวรทมการนาเทคโนโลย
Object มาใชงานกคอ การโปรแกรมเชงวตถ (Object –
Oriented Programming) นนเอง
![Page 24: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/24.jpg)
10 8 2 7 5 4 7 1 9 24 12 45 6
10 8 7 8 5
4 7 1 9 24
12 45 6
MAX
if data[i] >= data[i+1] thenbegin
elseMAX data[i+1]
end
SWAP
![Page 25: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/25.jpg)
Object – Oriented Programming (OOP) หรอ
การโปรแกรมเชงวตถ หมายถง การเขยนโปรแกรมท
ประกอบไปดวยกลมของ Object ซงแตละ Object จะ
ถกจดกลมอยในรปของคลาส (Class) โดยทแตละคลาส
สามารถมการถายทอดลกษณะ (Inheritance) กนลงมา
อยางเปนลาดบ (Hierarchy)
Object – Oriented Programming (OOP)
![Page 26: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/26.jpg)
1. ความสามารถในการสบทอด (Inheritance)
2. ความสามารถในการเกบซอน (Encapsulation)
3. ความสามารถในการแปลงราง (Polymorphism)
4. ความสามารถในการจดการโครงสรางขอมลแบบเชง
นาม (Abstract)
![Page 27: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/27.jpg)
Transform
Convert
![Page 28: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/28.jpg)
ความงาย จาวากลาวไดวาเปนภาษาทงายตอการศกษา
ภาษาจาวากาจดสวนทมความซบซอนในภาษา C++ ออกไป เชน multiple Inheritance, automatic type conversion, point และ memory management ของ C++ ทาใหภาษาจาวาใชงานงายและมความซบซอนนอยลงกวา C++ มาก
![Page 29: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/29.jpg)
เปนภาษาเชงวตถทสมบรณ
สวน C++ เปนภาษาผสม คอเขยนไดทงแบบ Procedural และ OOP ทสนบสนนหลกการเชงวตถ แตจาวาจะบงคบใหเขยนโปรแกรมไดดวยหลกการเชงวตถเทานน จงถอไดวาจาวาเปนภาษาทสามารถแสดงลกษณะเชงวตถไดอยางชดเจน เชนเดยวกบภาษา Smalltalk
![Page 30: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/30.jpg)
การกนการผดพลาด (Robust)
ภาษาจาวาเปนภาษาทมความคงทน เนองจากภาษาจาวาม
ระบบปองกนและสามารถกาจดความผดพลาดเลกๆ นอยๆ ท
อาจเกดขนไดในระบบ โดยไมตองหยดการทางานของ
โปรแกรมดวยสาเหตเพยงเลกนอยเหลาน นอกจากนภาษาจาวายงไมสนบสนนการทางานโดยใช pointer เพราะ pointer
เปนสาเหตททาใหเกดความผดพลาดไดงาย
![Page 31: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/31.jpg)
ความปลอดภยในการทจะประมวลผล (Secure)
ภาษาจาวาไดรบการพฒนาใหเปนภาษาสาหรบการ
ดาเนนงานบนระบบเนตเวรก ดงนนภาษาจาวาจงไดรบการ
สรางมาใหยดหลกความปลอดภยของขอมลบนระบบเนตเวรก
เปนสาคญ
![Page 32: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/32.jpg)
มลตเธรด (Multithread )
เปนการอนญาตใหโปรแกรมมากกวา 1 โปรแกรมสามารถ
ทางาน ณ เวลาเดยวกนได ทาใหระบบทางานแบบ real-time
ไดมากขน ซงในภาษาโปรแกรมอนๆ การทา Multithreading
นน จะมความซบซอนมาก แตในภาษาจาวาจะสามารถจดการกบ Multithreading ไดอยางงายดาย
![Page 33: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/33.jpg)
Architecture-neutral
จาวาสามารถทางานไดบนทกๆ ระบบ (Platform) เนองจากจาวาจะมการแปลงภาษา 2 ขนตอนคอ
![Page 34: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/34.jpg)
การ Compile และ Interpreter โดยเมอภาษาจาวาไดรบการ Compile ออกมาเปนภาษาของ JVM แลว (Java Virtual Machine หรอ bytecode โดยทเรยกวา bytecode เพราะทกๆ คาสงของ JVM มขนาดเพยง 1 byte เทานน) จะสามารถนาโคดทไดมาไปทางานไดบนเครองใดๆ ทมชดคาสงของ JVM ตดตงอย ดงนนภาษาจาวาจงเปนภาษาทไมขนอยกบระบบใดๆ
![Page 35: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/35.jpg)
• High Performance •
ในภาษาจาวาจะอนญาตใหเขยนโคดจาวาเพอเรยกใชงานโปรแกรมภาษาอนไดดวย เชน ภาษา C++ นอกจากน ในการประมวลผล JVM ไปเปนชดคาสงทสามารถทางานไดกบเครองคอมพวเตอรใดๆ นนจะใชเวลาในการประมวลผลนอยกวาเวลาทใชในการ Compile ภาษาอนๆ
![Page 36: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/36.jpg)
วตถ (Object) คอ ตวแทนของบคคล สถานท หรอสงของทสนใจในเหตการณหนง ซงอาจจบตองไดหรอจบตองไมได
![Page 37: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/37.jpg)
Attributes
Function
เกาอ
อาจารย
นกศกษา
คอมพวเตอร
แอปเปล
Tangilbe
wh h
b
r
![Page 38: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/38.jpg)
1. จบตองได / รปธรรม (Tangible)
◦ คน สงของ ตนไม พช สตว
2. มองไมเหน จบตองไมได (intangle)
◦ กฎหมาย บทเรยน เนอหา ภาพยนตร ...
![Page 39: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/39.jpg)
Object เปนองคประกอบสาคญของการเขยนโปรแกรมท
สามารถรบคาและแสดงสงคาได และจากนยาม Object คอ
ตวแทนของสงของทอยในโลกของความเปนจรง ซงอาจเปนสงทจบตองไดหรอไมได จะตองมคณลกษณะ (Attribute) ท
บงบอกวาเปน Object ของอะไร และมพฤตกรรม (Behavior)
ทบงบอกใหทราบวา Object นนทาอะไร ดงนน Object จะ
สามารถตอบสนองตอสงทกระทาในการรองขอสงตางๆ ได
![Page 40: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/40.jpg)
![Page 41: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/41.jpg)
![Page 42: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/42.jpg)
![Page 43: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/43.jpg)
1. identity คอ เอกลกษณเฉพาะตวททาให Object ของคลาส
หนงๆ แตกตางจาก Object ของอกหนงคลาสหนง ซงใน
ภาษาจาวา identity จะหมายถง Attribute หรอตวแปร
(Variable)
![Page 44: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/44.jpg)
2. State คอสถานะของ Object ณ เวลาหนงๆ ซงสามารถ
เปลยนแปลงไดเมอมการกระตนจาก Object อนโดยการสง
Message ในภาษาจาวา State จะหมายถงคาของ Attribute
(Value of Attribute)
![Page 45: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/45.jpg)
3. Behavior คอ พฤตกรรมท Object กระทาและตอบสนองทก
ครง โดยการกระตน Object อนโดยการสง Message ตอกนใน
ภาษาจาวา Behavior กคอ Method
![Page 46: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/46.jpg)
ในทาง OOP คณสมบตของ Object (identity+behavior)
ทคลายกนจะถกจดไวในคลาสเดยวกน ดงนนการแยกแยะ Object ทสรางจากคลาสเดยวกนจงใช State ในการพจารณา
เชน ชอของ Object (คาของตวแปร “name”) เปนตน สวน
การแยกแยะ Object ทสรางจากคลาสตางกน จะใช identity
และ Behavior ในการพจารณาเพราะ identity และ behavior
ของ Object ตางกนทาใหจดอยตางคลาสกนนนเอง
![Page 47: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/47.jpg)
แนวความคดทใชในการเขยนโปรแกรมในปจจบนจะใช 2 แนวความคดหลกๆ ไดแก แนวความคดการเขยนโปรแกรมแบบโครงสราง และแนวความคดเชงวตถ
![Page 48: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/48.jpg)
แนวความคดนเปนการจดการคาสงตางๆ ใหมรปแบบและมาตรฐานทสามารถเขยนโปรแกรมได ง าย อกทงยงมการตรวจสอบการทางานของโปรแกรมไดโดยไมย งยาก เมอเขยนโปรแกรมกเหมอนกบการเขยนหนงสอหรอการอานหนงสอ คอมจดเ รมต นจากซ ายไปขวา และจากบนลงล างเหมอนการอ านหนงสอ
![Page 49: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/49.jpg)
เปนการเขยนโปรแกรมเพอใหเปนไปตามหลกการเชงวตถ โดยผเขยนโปรแกรมตองพยายามมองรปแบบวตถใหออกกอน ซงตองอาศยจนตนาการพอสมควร
![Page 50: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/50.jpg)
แนวคดการเขยนโปรแกรมแบบดงเดมมกนยมใช การเขยนโปรแกรมเชงกระบวนการ (Procedural Programming) ซงใหความสาคญกบขนตอนกระบวนการททา โดยแบงโปรแกรมออกเปนสวนๆตามลาดบขนตอนการทางาน แตแนวคดการเขยนโปรแกรมเชงวตถนนใหความสาคญกบ ขอมล(data) และ พฤตกรรม(behavior) ของวตถ และความสมพนธกนระหวางวตถกนมากกวา
![Page 51: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/51.jpg)
![Page 52: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/52.jpg)
![Page 53: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/53.jpg)
เมอมการหยอดเหรยญเขาต: ตรวจสอบจานวนเหรยญและชนดของเหรยญ แสดงผลชนดของนาทสามารถเลอกซอได ตรวจสอบจานวนนากระปองทมอยในต
![Page 54: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/54.jpg)
รบผลการเลอกชนดนา สงนาทเลอกออกมาจากชอง จดเกบเงนเขาระบบ หากมเงนทอน ใหทอนเงนทเหลอ ทชองรบเงนทอน
![Page 55: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/55.jpg)
ตขายเครองดมอตโนมต ประกอบดวยสวนประกอบตางๆไดแก หนวยตรวจสอบและจดการเรองเงน หนวยจดการเครองดม หนวยแสดงผลและรอรบคาสง
![Page 56: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/56.jpg)
หนวยตรวจสอบและจดการเรองเงน มขอมลเกยวกบเงนทไดรบ และเงนทมอยในระบบ สามารถรบและตรวจสอบเงนทหยอดเขามาได และทอนเงนได
![Page 57: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/57.jpg)
หนวยจดการเครองดม มขอมลชนดของเครองดม จานวนเครองดม สามารถจดเตรยมชนดเครองดมทพอกบเงนทหยอด และสามารถจายเครองดมออกมาจากตได
![Page 58: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/58.jpg)
หนวยแสดงผลและรอรบคาสง มหนาทรอรบคาสง และแสดงผลเงนทหยอดเขามา
![Page 59: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/59.jpg)
ต.ย. สมมต ราคา สนคา 125.75 จายแบงคหนงพนบาท (1000) จะตอง
ทอนออกมาเปน 874.25 บาท
แบงค 500 จานวน 1 ฉบบ แบงค 100 จานวน 3 ฉบบ แบงค 50 จานวน 1 ฉบบ แบงค 20 จานวน 1 ฉบบ เหรยญ 10 จานวน 0 เหรยญ เหรยญ 5 จานวน 0 เหรยญ เหรยญ 1 จานวน 4 เหรยญ เหรยญ .50 จานวน 0 เหรยญ เหรยญ .25 จานวน 1 เหรยญ
![Page 60: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/60.jpg)
1. ตรวจสอบจานวนเงนและชนดของเงนทรบมา
2. ตรวจสอบราคา และ จานวนสนคา
3. คานวณจานวนเงนและแสดงผลจานวนเงนทงหมด
4. แสดงจานวนเงนทอนทงหมด
5. ทอนเงนโดยเลอกจากชนดและจานวนเงนมากสดกอน
6. ทอนเงนและชนดเงนตามเศษทคานวณแลว
7. จายสนคาตามรายการทเลอก
กลม 1
![Page 61: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/61.jpg)
1. ตองมเรมตน
2. ....
3. ....
4. ตองมสนสด
START
STOP
GIGO:Gabag In Gabag out
![Page 62: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/62.jpg)
1. ตองมเรมตน
2. ....
3. ....
4. ตองมสนสด
START
STOP
![Page 63: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/63.jpg)
ขนตอนแรก ตอง
รบจานวนเงนเขามา
รบ ราคาสนคา ทตองจาย
คด เงนทตอง ทอน คดยงไง .....
เงนทอน = เงนทรบเขามา - ราคาสนคา
• INPUT• PROCESS• OUTPUT
Exchange = Money - Price
![Page 64: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/64.jpg)
874.75 ทาอยางไรถงจะหาแบงค 500
เศษทเหลอ
MOD%
/ DIV ไมสนใจเศษ
\ MOD เอาเศษทเหลอ
B500 = Exchange / 500Tmp = Exchange % 500
274.751
![Page 65: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/65.jpg)
274.75 ทาอยางไรถงจะหาแบงค 100
เศษทเหลอ
MOD%
/ DIV ไมสนใจเศษ
\ MOD เอาเศษทเหลอ
B100 = Exchange / 100Tmp = Exchange % 100
274.751
![Page 66: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/66.jpg)
การเขยนโปรแกรมเชงวตถ เปนวธการเขยนโปรแกรมแบบใหม ซงจะเรยกโปรแกรมยอยททาหนาทเฉพาะวา Object และยงรวม data เขาเปนสวนของ Object ดวย นอกจากนโปรแกรมเชงวตถยงมโครงสรางพเศษนอกเหนอจาก Procedure Programming หรอ Module Programming คอ
![Page 67: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/67.jpg)
การทางานของแตละ Object จะไมสนสดลง เมอกระบวนการทางานของโปรแกรมจบการทางานบน Object นนแลว ซง Object ทอยในโปรแกรมเหลาน พรอมเสมอในการเรมทางานตอตาแหนงเดมเมอเกดการเรยกใชงาน Object อกครง ซงแตกตางจากการเขยนโปรแกรมในแบบอนๆ ทโปรแกรมยอยจะตองเรมการทางานใหมเมอถกเรยกใชอกครง ดงนนเทคนคนจงชวยลดปญหาทเกดขนจากการเขยนโปรแกรมดวยวธอนๆ ได
![Page 68: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/68.jpg)
Object 1
data
Object 2
data
Object 3
data
Object 4
data
แตละ Object สามารถตดตอสอสารกนไดโดยการสง Message ไปท Object อน
![Page 69: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/69.jpg)
• คลาส (Class) • วตถ (Object) • การหอหม (Encapsulation)• การรบทอดมรดก (Inheritance)• นามธรรม (Abstraction )• พอลมอรฟซม ( Polymorphism )
![Page 70: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/70.jpg)
คลาส (Class) - ประเภทของวตถ เปนการกาหนดวา วตถ จะประกอบไปดวย ขอมล (data) หรอคณสมบต (property) และ พฤตกรรม(behavior)หรอการกระทา(method) อะไรบาง ซง คลาส (เชน มนษย) เปนโครงสรางพนฐานของการเขยนโปรแกรมเชงวตถ
![Page 71: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/71.jpg)
วตถ (Object) - โดยมากจะเรยกวา ออบเจกต คอ ตวตน(instance) ของ คลาส(เชน นายทกษณ, นายสนธ) ซงจะเกดขนระหวาง run-time โดยแตละ ออบเจกต จะมขอมลเฉพาะของตวเอง ทาให ออบเจกต แตละ ออบเจกต ของ คลาส ซงใช source code เดยวกนมคณลกษณะและคณสมบตทแตกตางกน
![Page 72: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/72.jpg)
Encapsulation - การปดบงขอมล เปนวธการกาหนดสทธในการเขาถงขอมล หรอการกระทากบ ออบเจกต ของ คลาสนนๆ ทาใหแนใจไดวาขอมลของออบเจกตนนจะถกเปลยนแปลงแกไขผานทาง methods หรอ properties ทอนญาตเทานน (เชน การกาหนดตาแหนงทางการเมอง เปน public method ทผอนสามารกระทาได สวนการลาออกจากตาแหนง เปน private method ทมแต ออบเจกต ของ คลาส เทานนทจะสามารถทาได แตการกดดนและการขบไลสามารถสราง data ทอาจจะสงผลเกดการลาออกไดเชนกน)
![Page 73: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/73.jpg)
Inheritance - การสบทอดคณสมบต เปนวธการสราง คลาสยอย ทเรยกวาซบคลาส (subclass) ซงจะเปนกาหนดประเภทของวตถใหจาเพาะเจาะจงขน ซง ซบคลาส จะไดรบถายทอดคณสมบตตางๆมาจากคลาสหลกดวย (เชน คลาส มนษย สบทอดมาจาก คลาส สงมชวต)
![Page 74: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/74.jpg)
![Page 75: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/75.jpg)
![Page 76: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/76.jpg)
Abstraction - นามธรรม เปนการแสดงถงคณลกษณะและพฤตกรรมของ object เทาทจาเปนตองรบรและใชงาน โดยซอนสวนทเหลอเอาไวเพอไมใหเกดความสบสน เชน ตามปกตแลว นายนฐพงศ จดเปนตวตนของ คลาสมนษย ซงจะมพฤตกรรม การกระทาทกอยางทตามทกาหนดไวตามโครงสรางของ คลาส มนษย แตในบางกรณทนาไปใชงาน เราไมตองการใหเกดการสบสนตอการใชงานหรอการจดประเภทมากเราสามารถจดการหรอใชงาน ออบเจกต นายนฐพงศ ใหอยในรปของสงมชวต กได
![Page 77: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/77.jpg)
Polymorphism - ภาวะทมหลายรปแบบ เปนวธการกาหนดรปแบบการกระทาทเหมอนกนแตไดผลทแตกตางกน เชน การเปลงเสยง เปน method หลกของ คลาส สงมชวต ซงมคลาส มนษย และคลาสสนข เปน ซบคลาส แตผลของการเปลงเสยงของออบเจกตจากคลาสทงสองจะออกมาไมเหมอนกน
![Page 78: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/78.jpg)
import javax.swing.*;
import java.awt.*;
public class CardView extends JLable
{
private ImageIcon icon;
![Page 79: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/79.jpg)
public CardView(VCard card)
{
getImage(card.getImage());
setIcon(icon);
setBackground(Color.white);
setOpaque(true);
}
Object 1
data
![Page 80: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/80.jpg)
private void getImage(String name)
{
java.net.URL url =
this.getClass().getResource(name);
icon = new ImageIcon(url);
}
}
Object 2
data
![Page 81: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/81.jpg)
…Break..
![Page 82: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/82.jpg)
เปนการจาลองความเปนจรงในชวตความเปนอยของมนษยทจะประกอบดวย คน สตว สงของ และใชสงตางๆ เพอแกปญหา โดยแตละสง มหนาทในการแกปญหานน ๆ
ตองการหาความบนเทงดวยดนตรกตองมสงตางๆ คอเครองดนตรและคนเลนดนตร เปนตน
![Page 83: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/83.jpg)
แกไขปญหาดวยโปรแกรมททาตามลาดบขนตอนทไดกาหนดไว
มการเรยกใชโปรแกรมยอยทสรางขน
แกปญหาโดยมองสงตาง ๆทอยในโปรแกรมเปนวตถ
วตถแตละชน มคณสมบต และความสามารถแตกตางกนออกไป
วตถตดตอการดวยวธการสงขาวสารถงกน
#include <stdio.h>
main () {
int width , length, area ;
width = 10 ;
length = 5 ;
area = width * length ;
printf (“Area = %d\n”,area) ;
return 0
}
![Page 84: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/84.jpg)
![Page 85: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/85.jpg)
ทกๆ สงเปนวตถ
โปรแกรม คอ กลมของวตถทสงสารบอกกนเพอทางาน
วตถแตละวตถมหนวยความจา
วตถตองมชนด
วตถทจดอยในประเภทเดยวกนยอมไดรบขาวสารเหมอนกน
Alan key เปนผหนงทพฒนาตวแปร small Talk ซงเปนตนแบบของการเขยนโปรแกรมเชงวตถ ไดใหนยามของภาษาเชงวตถไวดงน
![Page 86: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/86.jpg)
องคประกอบของโปรแกรมคอมพวเตอรทก ๆ สวนจะตองเปนวตถซงกฎขอนเองททาใหลามแปลภาษาสวนมากรวมทง JAVA ดวย ไมเปนภาษาเชงวตถแบบบรสทธเพราะในลามแปลภาษา JAVA ยงมบางสวนทไมเปนวตถ เชน การกาหนดตวแปร เปนตน
Object
![Page 87: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/87.jpg)
โปรแกรมในความหมายของการเขยนโปรแกรมเชงวตถ กคอ กลมของวตถทสงขอความขาวสาร(Message) ถงกนและกนเพอบอกใหวตถทางาน
![Page 88: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/88.jpg)
วตถในความหมายของการเขยนโปรแกรมเชงวตถ จะตองมหนวยความจาของตวเอง หรอนนคอสวนทเกบขอมลสวนของวตถนนๆ เองซงเราเรยกวา attribute
สวนของขอมลนอาจจะประกอบขนจากวตถอนๆ ได เปนทมาของการเกดคณสมบตการถายทอดและคณสมบตของ
องคประกอบคอมโพสตMobilePhone
String bandnameButton buttonScreen screenAntenna antennaSimm simNet
call()receive()hangup()sendSMS()
Attribute
![Page 89: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/89.jpg)
![Page 90: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/90.jpg)
ชนดของวตถดงกลาวกคอคลาส (Class) ในการเขยนโปรแกรมเชงวตถจะตองเขยนคลาสขนมากอนเสมอ แลว
จงจะสรางวตถจากคลาส ดงนนวตถจงจะตองอยในคลาสใดคลาสหนง
ดงนนคลาสเปรยบเหมอนแมพมพ สวนวตถกคอสงทเกดจากแมพมพ วตถทเกดจากคลาสเดยวกนจงมคณสมบตพนฐานเหมอนกน
![Page 91: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/91.jpg)
MobilePhone
String bandnameButton buttonScreen screenAntenna antennaSimm simNet
call()receive()hangup()sendSMS()
:siemens
:ericsson
:nokia
![Page 92: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/92.jpg)
วตถทอยในประเภทเดยวกนยอมไดขาวสารเหมอนกน คณสมบตขอนทาใหการเขยนโปรแกรมเชงวตถมประสทธภาพเพมขนเพราะชนดของวตถมไดกาหนดหรออยอยางโดด ๆ แตสามารถจดเปนกลม ผเขยนคาสงสามารถกาหนดชนดยอย ๆ ของวตถไดอกเชน คลาสคอ shape เราสามารถแตกออกเปนชนดทจาเพาะลงไปเปน Circle, Triangle, Rectangle เปนตน ดงนนเมอวตถในคลาสCircle สามารถไดรบขาวสารเหมอนกบ Triangle และ Rectangle
![Page 93: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/93.jpg)
การซอนรายละเอยด (information hiding) การเชอมตอ (Interface) การนาวตถมาใชใหม (Reusable) การพองรป: หนงรปหลายพฤตกรรม (Polymorphism)
![Page 94: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/94.jpg)
มผสงเกตเหนวาในชวตประจาวนของเรานน ไมจาเปนตองทราบหรอรทกเรองกสามารถใชงานสงของนนๆ ได เชน
โทรทศนทมอยตามบาน เรา
ไมตองทราบการทางานของ
อปกรณภายในของมน แต
เรากสามารถเปดเครองและ
ดรายการโปรดของเราได
เพยงรวธการกดปมตางๆ
![Page 95: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/95.jpg)
โดยปรกตจะเชอมตอระหวางผใชกบคอมพวเตอร เรยกวา user interface
แตคาวาอนเตอร เฟสสาหรบวตถคอ สวนทบอกวาวตถนนใหบรการหรอสามารถทาอะไรไดบาง
![Page 96: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/96.jpg)
ชฟมสวนทใชงานการตดตอกบอปกรณภายนอก interface
Information hidingเราจะไมรการทางานภายในของชฟเพราะถกซอนรายละเอยดไวแตยงสามารถใชงานตามปกตหากชฟชนนเสยกสามารถหาตวอนมาเสยบแทนไดเลย
![Page 97: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/97.jpg)
จดประสงคใหญของการเขยนโปรแกรมเชงวตถกคอการนาสวนตางๆ ของวตถทสรางขนกลบมาใชใหมหรอทเรยกในภาษาองกฤษวา “reuse” เมอมวตถถกสรางขนมา กสามารถนาวตถตางๆ มาประกอบกนเปนวตถอกชนดหนงได เพอใหวตถใหมมความสามารถมากกวาเดม เชนกรณของรถยนตสามารถประกอบขนจากเครองยนต ตวถง ประต และลอ เปนตน
![Page 98: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/98.jpg)
![Page 99: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/99.jpg)
รากฐานของการพองรปคอคณสมบตการถายทอด คณสมบตการถายทอดยนยนไดวาคลาสลกทเกดจากคลาสแมเดยวกนยอม
มคณสมบตเหมอนกน
เปนทมาของหนงรปหลายพฤตกรรม
คลาสแมคอ Shapeคลาสลกคอ Circle, Triangle, Rectangle มคณสมบตเหมอนคลาสแมทกประการ
![Page 100: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/100.jpg)
Shape
+draw()+erase()
Circle
+draw()+erase()
Line
+draw()+erase()
Rectangle
+draw()+erase()
![Page 101: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/101.jpg)
คลาสเปนเหมอนสวนของแมพมพ เพอบอกลกษณะวาวตถในคลาสนมลกษณะและพฤตกรรมเปนอยางไร
วตถเปนสงทถกสรางขนมาจากคลาสเพอใชงาน กาหนดคาตางๆ สงขอความสงใหวตถทางาน
คลาสสเหลยมผนผาคณสมบต:กวาง, ยาวเมธทอด:คานวณพนท
วตถA:สเหลยมผนผากวาง 2 ยาว 3
เมธทอด:คานวณพนท
![Page 102: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/102.jpg)
![Page 103: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/103.jpg)
วตถในโลกความจรง มองคประกอบสาคญสองสงคอ
สถานะ (State)
พฤตกรรม (behavior)
สถานะ ชอ , ส , สายพนธ
พฤตกรรม เหา , วง , กระดกหาง
สถานะ ตาแหนงเกยรปจจบน ,
ความเรวรอบปจจบน , ความเรวรถ
พฤตกรรม เปลยนเกยร , เปลยนความเรวรอบ,
เบรค
![Page 104: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/104.jpg)
สถานะ ปด , เปด
พฤตกรรม กดปด , กดเปด
สถานะ ปด, เปด , ระดบเสยง, สถานปจจบน
พฤตกรรม กดปด, กดเปด , ลดเสยง ,เรงเสยง ,
คนหาสญญาณ
โคมไฟ
วทย
![Page 105: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/105.jpg)
คลายคลงกบวตถในโลกความจรง โดยจะประกอบไปดวย สถานะ และ พฤตกรรมเชนเดยวกน
เกบสถานะของวตถไวใน Field หรอ Attribute (ตวแปรในโปรแกรม) และแสดงพฤตกรรมโดยผาน Method (ฟงกชนการทางานใน
โปรแกรม)
![Page 106: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/106.jpg)
Method ทาหนาทเปลยนแปลงสถานะ(Field)ซงอยในวตถนน ๆ และทาหนาทตดตอระหวางวตถกบวตถ
Method Change gears ทาหนาทเปลยน เกยร
Method Brake ทาหนาทหยดรถ
Method Change cadence ทาหนาทเปลยน
ความเรวรอบการป น
![Page 107: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/107.jpg)
Modularity : โคดของโปรแกรมแบบ Object สามารถแยกสวนกนเขยนไดอยางเปนอสระ
Information-hiding : รายละเอยดและขอมลถกซอนอยภายใน Object การปรบเปลยนขอมลภายใน Object ตองทาผาน Method เทานน
Code re-use : โคดของโปรแกรมสามารถนากลบมาใชใหมไดอยางสะดวก ทาใหพฒนาโปรแกรมไดอยางรวดเรว
![Page 108: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/108.jpg)
ดาวนโหลดชดพฒนาภาษาจาวาทเวบต
http://java.sun.com/j2se
Java virtual machine : JRE (Java Runtime Environment)Java Developer Kit : JDK
![Page 109: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/109.jpg)
ใหนกศกษายกตวอยางวตถในโลกความจรง 1 ตวอยาง แลวแสดงใหเหนวา สถานะ (State) และ พฤตกรรม(Behavior) ของวตถนนมอะไรบาง
![Page 110: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/110.jpg)
OOP 2/2550ดร.สขสถต มสถตย 110
1. จงบอกประโยชนของการเขยนโปรแกรมเชงวตถ
2. สถานะของออบเจกตหมายความวาอะไร?
3. จงจาแนกสงตอไปนวาสงใดเปนคลาส สงใดเปนออบเจกต ◦ สมด, บานเลขท 97/8, ขนม, นายนฐพงศ สงเนยม
4. จงหาขอมลและพฤตกรรมทเปนไปไดของออบเจกตของคลาสตอไปน◦ สนข, รถยนต, โซฟา
5. จงแยกแยะวาสงใดเปนซปเปอรคลาสและซบคลาส • ตนไม, ไมดอก
• พนกงาน, ผจดการ
• เคก, ขนม
![Page 111: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/111.jpg)
IDE : integrate development environment
case sensitive สนใจตวพมพเลก/ใหญ
int y;
Y = 8;
c , c++ , c# , java , perl , php
none case sensitive ไมสนใจ
-------------------------------
1. หามมชองวาง
2. หามขนตนดวยตวเลข เชน 4Car , 5MB
MB5
![Page 112: By : Dr.Nattapong Songneam ...siam2dev.net/E_Learning/OOP/Lec01_OOP_concept_last... · C++ . ออกไป เช น multiple Inheritance, automatic type conversion, point และ](https://reader034.fdocuments.net/reader034/viewer/2022050511/5f9bf3589c71b66eee49df93/html5/thumbnails/112.jpg)
www.siam2dev.net
หนา E-Learning
---------
1. หามตงชอขนตนดวยตวเลข
2x , 5t , 8u
2. หามมชองวาง
1.dim x y as int16
2. int x y;
3. int my name is;
4. int my_name_is;
5. int my-name-is;
6 int my*name/is;