V
V
Vitaly Stolyarov2017-04-06 18:06:39
Career in IT
Vitaly Stolyarov, 2017-04-06 18:06:39

"Method overloading is not polymorphism" or ignorance of the interviewer?

Here is a comment I had to hear from the interviewer. In answer to the question "What is polymorphism?" gave a general definition of polymorphism, which is the ability to change the behavior of an object with different data types, for example, when overloading methods.
At first, I even doubted it myself, but then I googled it - after all, this is a special case of polymorphism, and not just override of virtual methods.
What do you think is polymorphism in the implementation example in the code?
And what is the threat of employment in a company with such questions at interviews (from your experience)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
devalone, 2017-04-06
@devalone

On Wikipedia the definition is

In programming languages ​​and type theory, polymorphism is the ability of a function to handle data of different types.
and special cases of polymorphism "ad hoc polymorphism" and "parametric polymorphism" are given.
In my opinion, the definition of "one interface and many implementations" is much better suited, overloaded functions, inheritance with virtual functions and templates fit this definition. IMHO, it's better when a person understands what it is and can explain in his own words, let's say with examples in the code, than when he memorized 2 pages of text from Wikipedia or a book and reads it without hesitation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question