Posted by Samuel on 10/11/05 12:04
In general, OOP is more or less what your example shows. The class
defines what the object is and can do, while the object actually *is*
something (an instance of the class) and *does* something. See if this
pseudocode helps...
Class Dog
{
var race;
var food_it_likes;
function Bark
{
....
}
function Poop
{
....
}
} //End Dog Class
//You have just defined what a dog is and can do, so that you can have
multiple dogs doing stuff. Then, in your program...
Dog Vincent;
Dog Toby;
Toby.race = "Scottish Terrier";
Toby.food_it_likes = "Tasty Chicken";
Vincent.race = "Chiuaua";
Vincent.food_it_likes = "Human Flesh";
Vincent.Bark;
Toby.Poop;
//You now *actually* have two dogs who can bark and poop. One is
barking (Vincent the scary assasin little chiuaua), and the other is
pooping (Toby the elegant black Scottish).
Greetings
[Back to original message]
|