| rmxhaha (26) | |||||
I am just wondering which is better
or
I admit typing the switch is a lot faster than doing polymorphism and hypothetically speaking I think the polymorphism is slighlty more efficient But if it just for slight perfomence difference, than I think I will go with switch cause it safes a lot of time. But just want to know which is better ? | |||||
|
|
|||||
| EssGeEich (681) | |
| I think polymorphism is better? Depends on compiler optimizations. If that's a bad optimizer, it will translate the switch with a bunch of if/then/else, otherwise it will be translated as a jumptable (Virtual classes have kinda a jumptable, the vtable) | |
|
Last edited on
|
|
| rmxhaha (26) | |
| is TDM GCC 4.7.1 good enough ?? | |
|
|
|
| JLBorges (1335) | |
|
> I admit typing the switch is a lot faster than doing polymorphism Right now, yes. But if tomorrow you wand to add a couple of more birds, say thrush and wren, (or for that matter some more operations) you might find that a polymorphic hierarchy of birds is easier to maintain. Either may be better - you need to take a decision based on your expectation of how your program might evolve. | |
|
|
|
| rmxhaha (26) | |
|
Ok... Thanx for your answers I think I will go with polymorphism for now I think the only thing that bothers my mind is that it's hard to inheritance the contstructor... | |
|
|
|