Creating a Class
You can model anything you want using classes. The best way to explain it
is to show you an example. Let us write a simple class, Cat, which
represents a cat. Note this is not just a particular cat in question but also any
cat. What information do you want to know about the cat? Cats all have a
name; some can sit while others can spit. With this, we have important
information such as their names, ages, and behaviors (sitting and spitting).
We can use this to create a class since it is common with most cats. Once
we write our class, we can use it to make individual instances.
Do'stlaringiz bilan baham: |