What is needed for a C++ member function of a class to behave polymorphic?


Please can anyone answer me to this, and if you can give me some example. Thanks.

Thank you.

Look at the C++ section of this link:
wiki: Polymorphism_in_object-oriented_programming

I guess the talk() function is behaving polymorphic, because its in each of the inherited classes.

No you are wrong according to what I have learn. There are
two types of polymorphism. Dynamic and static. Study them
carefully.

Even overloading is also one category of polymorphism ,it's
static polymorphism. In java yes , but in C++ a non virtual
overriding is also a static polymorphism. Please correct me
if I wrong. I even not read this very carefully.

and the dynamic polymorphism is implemented using the virtual
keyword in the C++.

and there are many old "C" style of ways to implement the
dynamic polymorphism , shuch as function pointers . But now
in C++ use virtual functions is recommanded.

I wouldn't go as far to say that i am wrong, my answer was just too specific.
if you look at the talk() function, it is actually declared as virtual, so therefore it is an example of dynamic polymorphism.

anyway take a dictionary and look at the meaning polymorphism ,
means many forms .

for a example you can open a door , or you can open a newspaper or
you can open a file. So there are many different forms for different types
of specifications . ( source: from a famous UML Book).


Most ppl are doing this mistake , this is a common
mistake.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.