Programming and Graphics

(Kiana) #1

Classes and Objects^6


The intelligent mind has a natural tendency to classify objects, items, concepts,
and abstract notions into groups recognized by given names:



  • Races in anthropology

  • Species in biology

  • Sets and spaces in mathematics

  • Elementary particles in physics

  • Elementary motions in fluid mechanics


The groups are distinguished by common features and properties, concisely
calledattributes, and the members interact by a well-defined set of rules.


An entity that belongs to a group is formally called amember,andan
action that can modify a member, make a member disappear, or generate an
offspring is called amember function.^1 Examples of groups are:


The set of natural numbers: 1, 2, 3, 4, ...:

The member function “addition of unity” operating on the member “2”
produces the member “3”.

The set of integers: ..., -4, -3, -2, -1, 0, 1, 2, 3, 4, ...:

The member function “subtraction of unity” operating on the member
“-3” produces the member “-4”.

The set of rational numbers,m/n,wheremandnare integers:

The member function “addition” operating on the membersm/nand
k/lproduces the member (lm+kn)/(nl).

(^1) Groucho Marx once said: “I do not want to belong to any club that would accept me as
amember.”(http://www.groucho-marx.com).

Free download pdf