![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Hobbyist Programmer
Join Date: Oct 2005
Posts: 134
Rep Power: 4
![]() |
In order to not be abstract, a subclass must define its own version of Feed(). Suppose I made a Shark subclass (poor other fish trying to eat and they get eaten by a shark), and it didn't implement Feed(). This is valid class, but it would be abstract because it didn't implement Feed. And therefore, you could not declare a Shark object. But if you had several Shark subclasses (GreatWhite, HammerHead, etc), and they implemented Feed(), they would not be abstract.
|
|
|
|
|
|
#12 | |
|
Professional Programmer
|
In other words(easier to understand), an abstract class is used as an outline. You won't use an abstract class to create objects and such, the concrete(derived) classes of the fish(such as sunfish, shark, whale) will be the objects the programmer would create.
__________________
▄▄▄▄ Quote:
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it. Download Code::Blocks now! ▄▄▄▄ |
|
|
|
|
|
|
#13 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
Correct jayme, although in this Fish example, it might be more appropriate to say that concrete classes will be particular species of fish. Of course, that depends on what the application is trying to do ..... if there is a valid reason for having a concrete Shark class (as opposed to an abstract Shark and concrete WhitePointer and GreyNurse) then that's a design decision. Most real-world designs involve some form of trade-off like that. It might also be appropriate to have a concrete Shark class if data characterising each shark are being read from some form of database (we wouldn't want the program capability to be limited just because we forgot to create a class for a particular type of shark, even if it can be represented in the database).
And a whale is not a fish ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|