![]() |
|
#1
|
|||
|
|||
Polymorphic programingHi everybody,
I don't have any problems with a program or anything like that, so i am not sure if this forum is the correct place to ask this question, but ill try and see what happens. I am currently learning about polymorphic programming and inheritance, but the book i am reading only gives one exercise in this area; "Create a shape hierarchy, where TwoDShape and ThreeDShape inherit form class Shape....ect." I'm sure a lot of you have seen the exercise before. So anyway, i was wondering if anyone out there had any good ideas for exercises to do with polymorphism, because all i can find is the one i just mentioned or a simple variation of it. Any ideas are welcome. Harry. |
|||
|
#2
|
||||
|
||||
Re: polymorphic programingOne example, using animals (although it's a short example) can be found here.
Others that I've seen before: 1. Vehicle base class, inherited by Truck, Car, etc. classes. (including bicycles, segway's as these can also be 'vehicles') 2. Employee base class, inherited by CommissionEmployee, HourlyEmployee, and SalaryEmployee classes. (plus Faculty, Staff could be other example possibilities) 3. Account base class, inherited by CheckingAccount, SavingsAccount, CreditLineAccount classes. 4. Student base class, inherited by GraduateStudent, UndergraduateStudent classes. 5. Loan base class, inherited by CarLoan, MortgageLoan, HomeImprovementLoan classes. I'm sure there's more, but I'll start with those. Maybe others can offer more examples. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! Last edited by TurboPT : 21-Jun-2008 at 15:58.
|
|
#3
|
|||
|
|||
Re: polymorphic programingQuote:
Most GUI libraries are implemented in this manner for exactly this reason. |
|
#4
|
|||
|
|||
Re: Polymorphic programingPolymorphism is divided into two section static and dynamic.
Static polymorphism consist of function overloading and operator overloading. Dynamic overloading is the evaluation based on object content rather than type. References is here: gd.tuwien.ac.at |
Recent GIDBlog
Install Adobe Flash - Without Administrator Rights by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I load DLL files for windows programing in the Microsoft visual c++? | mhasan_mitul | C++ Forum | 1 | 01-Nov-2006 14:42 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The