R
richard pickworth
Can anyone explain polymorphism?(very simply).
thanks
richard
thanks
richard
Polymorphism means that, given a single interface, you can observe
different behavior from parameters of different (but related) types.
The two main types of polymorphism are run-time (implemented as
inheritance and virtual functions), and compile-time (implemented as
templates). /david
richard said:Can anyone explain polymorphism?(very simply).
andy E said:A crow is a bird.
A parrot is a bird.
Tell the bird to squawk and it makes a sound dependent on it's type.
Andy
andy said:(e-mail address removed) wrote:
A crow is a bird.
A parrot is a bird.
Tell the bird to squawk and it makes a sound dependent on it's type.
Andy
Peter Julian said:Not bad.
Suresh said:- Every variable has two types associated with it. Static type and
dynamic type.Static type is based on the way it was declared. In above
example static type of b is base*. Dynamic type is comes from the
context. In the above example base class pointer b is pointing derived
class object. So dynamic type of the b is derived *.
"circle is a shape"
class base {};
class derived {};
base *b = new derived();
richard said:I wan't expecting such a good response.
If two objects share the same interface, does that make them polymorphic?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.