ผลต่างระหว่างรุ่นของ "Adt lab/classes"
Jittat (คุย | มีส่วนร่วม) |
Jittat (คุย | มีส่วนร่วม) |
||
แถว 14: | แถว 14: | ||
=== Review of basic terminologies === | === Review of basic terminologies === | ||
− | + | '''Classes''' are user-defined types. An '''object'' is an instance of a class. A class can contain many members: '''data members''', '''member functions''', constants. (Note that in C++, we do not call member functions as ''methods''.) Members can have access labels: '''public''', '''protected''', '''private'''. Some member can be '''static''' member, i.e., it is a member that is shared among all objects in the class. | |
− | |||
=== Dog class === | === Dog class === |
รุ่นแก้ไขเมื่อ 23:33, 3 กันยายน 2558
- This is part of Adt lab
C++ is a class-based object-oriented programming language. Every object in C++ must be an instance of some class. If you are familiar with OOP in Java, most ideas should be familiar; you may need to learn a few new terminologies. There are one main difference: in C++ you have freedom to use an object as a value-typed variable; in Java, every object is a reference variable. We will look at these basic idea this week.
เนื้อหา
On-line resources
- C++ Programming on wikibooks: classes section
- Tutorial from cplusplus.com
Classes in C++
Review of basic terminologies
'Classes are user-defined types. An object is an instance of a class. A class can contain many members: data members, member functions, constants. (Note that in C++, we do not call member functions as methods.) Members can have access labels: public, protected, private. Some member can be static member, i.e., it is a member that is shared among all objects in the class.