4
votes
3answers
366 views

What is the process of determining which method in a class hierarchy should execute known as?

I thought I understood inheritance and polymorphism, but I was given this question, and I can't, for the life of me, figure out what the proper answer is or what they're trying to get at: The ...
-4
votes
0answers
53 views

How to explain Inheritance and Polymorphism to NON CS Students with examples? [on hold]

I was wondering if some one could help me with explaining Inheritance and Polymorphism with real world examples to NON CS students preparing for a job interview in a IT firm. PS: My first question on ...
1
vote
2answers
79 views

Does subtype polymorphism distinguish between inheriting behavior, or inheriting an interface?

To provide some context, I've seen some comments lately that equate inheriting behavior from a supertype, with inheriting a pure interface with no behavior. But there are pretty significant, and ...
1
vote
5answers
143 views

Clarification about Polymorphism / Inheritance

I am trying to better my understanding of polymorphism. Say I have a base class called baseClass with one method called foo() and I have three derived classes called derived1 , derived2 and derived3 ...
1
vote
1answer
351 views

Readability vs benefits of polymorphism

We are dealing with a lot of CRUD operations in our application. Each database table has one or more corresponding SQLContainer instances to perform various types of operations. All of these ...
2
votes
4answers
485 views

Confusion about inheritance

I know I might get downvoted for this, but I'm really curious. I was taught that inheritance is a very powerful polymorphism tool, but I can't seem to use it well in real cases. So far, I can only ...
13
votes
4answers
625 views

Switch vs Polymorphism when dealing with model and view

I can't figure out a better solution to my problem. I have a view controller that presents a list of elements. Those elements are models that can be an instance of B, C, D, etc and inherit from A. So ...
1
vote
3answers
335 views

Is it bad practice to check object types with an identifying member variable?

Preamble: I am making a simple board game in C++, in which AI characters move around squares on the board. There are different types of squares, each inherited from an abstract class, each with ...
2
votes
2answers
866 views

Interview question “What is virtual function”

It was funny for me, and I'm interesting the reaction for this question of the community. It was interview for C++/Qt developer, and question was asked "What is virtual function". Not something like ...
6
votes
4answers
418 views

Besides polymorphism, what's compelling about OOP? [duplicate]

When I first came to OOP (at first in Java, and then C++) after years of working in C and VB, it was amazing. The idea of extending existing behaviour and operating generically over things of related ...
12
votes
6answers
454 views

OO Design, how to model Tonal Harmony?

I have started to write a program in C++ 11 that would analyse chords, scales, and harmony. The biggest problem I am having in my design phase, is that the note 'C' is a note, a type of chord (Cmaj, ...
1
vote
1answer
539 views

Can the Abstract Factory pattern be considered as a case of polymorphism?

I was looking for a pattern/solution that allows me call a method as a runtime exception in a group of different methods without using Reflection. I've recently become aware of the Abstract Factory ...
11
votes
5answers
1k views

Is duck typing a subset of polymorphism

From Polymorphism on WIkipedia In computer science, polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface. From duck ...