Академический Документы
Профессиональный Документы
Культура Документы
Programming
Chapter 2 introduces Object
Oriented Programming.
OOP is a relatively new
approach to programming
which supports the creation
of new data types and
operations to manipulate
those types.
Data Structures
This presentation introduces
and Other Objects
Using C++ OOP.
What is this Object ?
There is no real
answer to the question,
but we’ll call it a
“thinking cap”.
The plan is to describe
a thinking cap by
telling you what
actions can be done to
it.
Using the Object’s Slots
I should
study harder !
Thinking Cap Implementation
};
Thinking Cap Implementation
class thinking_cap
{
public:
void slots(char new_green[ ], char new_red[ ]);
void push_green( ) const;
void push_red( ) const;
private:
char green_string[50];
char red_string[50];
};
Files for the Thinking Cap
The member
function
activation int main( )
{
consists of four thinking_cap student;
parts, starting thinking_cap fan;
with the object .
student slots( "Hello", "Goodbye");
name.
Using the Thinking Cap
Theinstance
name is followed
by a period. int main( )
{
thinking_cap student;
thinking_cap fan;
.
student slots( "Hello", "Goodbye");
Using the Thinking Cap
Hello
Go Cougars!
int main( )
{ Goodbye
thinking_cap student;
thinking_cap fan;
student.slots( "Hello", "Goodbye");
fan.slots( "Go Cougars!", "Boo!");
student.push_green( );
fan.push_green( );
student.push_red( );
...
What you know about Objects
}
strcpy(red_string, new_red); fan.green_string
fan.red_string
?
Thinking Cap Implementation
void thinking_cap::push_green
{
}
Thinking Cap Implementation
Here is the implementation of the push_green
member function, which prints the green message:
void thinking_cap::push_green
{
Some artwork in the presentation is used with permission from Presentation Task Force
(copyright New Vision Technologies Inc.) and Corel Gallery Clipart Catalog (copyright
Corel Corporation, 3G Graphics Inc., Archive Arts, Cartesia Software, Image Club
Graphics Inc., One Mile Up Inc., TechPool Studios, Totem Graphics Inc.).
Students and instructors who use Data Structures and Other Objects Using C++ are
welcome to use this presentation however they see fit, so long as this copyright notice
remains intact.
THE END