member variables . . This ensures that This ensures that nobody can directly nobody can directly access this access this information. The information. The only access is th[r]
(1)(2)What is this Object ?
There is no real
There is no real
answer to the question,
answer to the question,
but we’ll call it a
but we’ll call it a
“thinking cap”
“thinking cap”
The plan is to describe
The plan is to describe
a thinking cap by
a thinking cap by
telling you what
telling you what
actions can be done to
actions can be done to
it
(3)Using the Object’s Slots
You may put a piece of
You may put a piece of
paper in each of the two
paper in each of the two
slots (green and red), with a
slots (green and red), with a
sentence written on each
sentence written on each
You may push the green
You may push the green
button and the thinking cap
button and the thinking cap
will speak the sentence
will speak the sentence
from the green slot’s paper
from the green slot’s paper
And same for the red
And same for the red
button
(4)(5)Example
(6)Example
(7)Thinking Cap Implementation
We can implement the
We can implement the
thinking cap using a
thinking cap using a
data type called a
data type called a
class
class..
class thinking_cap {
(8)Thinking Cap Implementation The class will have The class will have two components called two components called green_string
green_string and and
red_string
red_string. These . These
(9)Thinking Cap Implementation
The two components
The two components
will be
will be private private member variables
(10)Thinking Cap Implementation
In a class, the
In a class, the
functions which
functions which
manipulate the class
manipulate the class
are also listed
are also listed
class thinking_cap {
public: . . private:
char green_string[50]; char red_string[50]; };
Prototypes for the thinking cap
functions go here, after the word