Polymorphism

I studied C++ syntax and OOP and could not learn about Polymorphism. Can anyone explain me in which area that i will need polymorphism
C++ uses the same names in different contexts to different effect. Rather than trying to establish what are the OO features of the language, it maybe moire useful to start with a simple object oriented design and work thru implementing that.
http://www.cplusplus.com/forum/beginner/98418/

check out post #2 from vlad. It's a good example of polymorphism.
It doesn't really explain anything. It's just sample code.

The field is just too big and we don't know how much you already know, in order to decide where to start.

It's best to start with trying to implemnent a simple design. And no, you shouldn't be writing OO code without some kind of design behind it.
Last edited on
Thanks guys!
By the way I was just referring a book called Object Oriented programming with C++. I just referred till associations and aggregation following Inheritance.I am more into game programming and haven't felt that i have used them yet in my programming using SDL library.

What I want to know is in which case do I need the knowledge of polymorphism in game programming?

Your support will help me to master programming for perfection. Cheers!
It doesn't really explain anything. It's just sample code.


So you think this was a better explanation?:

C++ uses the same names in different contexts to different effect.


:)
What I want to know is in which case do I need the knowledge of polymorphism in game programming?

Any situation in which you might want several objects of different types, but which all share some common properties or behaviour, so they derive from some common type, or conform to some common interface.

Do you have different types of monster, all of which can attack, but which attack in different ways? Polymorphism might be what you need.

Do you have different types of objects, all of which can be used, but which have different effects when used? Polymorphism might be what you need.

There's no single area in which you will or won't need polymorphism. It's a fundamental pattern in OO design - so fundamental, that we don't even tend to call it a "pattern", because it's existed since before the word "pattern" came into vogue. It's widely applicable to a huge range of situations.

It's one of the absolute fundamentals of OO design. You really should try and find a good tutorial source, because it's pretty crucial to understand it.
Last edited on
MikeyBoy you are the boy!
Thanks mate.You gave the perfect answer i was looking for.I should learn polymorphism.Keep on rocking!
Topic archived. No new replies allowed.