Skip to main content

Questions tagged [polymorphism]

In computer science, polymorphism is a programming language feature that allows values of different data types to be handled in a uniform manner.

14 votes
8 answers
12k views

How do you do polymorphism in Ruby?

In C#, I can do this: class Program { static void Main(string[] args) { List<Animal> animals = new List<Animal>(); animals.Add(new Dog()); animals.Add(new ...
FlySwat's user avatar
  • 175k
36 votes
7 answers
11k views

What's the difference between Polymorphism and Multiple Dispatch?

...or are they the same thing? I notice that each has its own Wikipedia entry: Polymorphism, Multiple Dispatch, but I'm having trouble seeing how the concepts differ. Edit: And how does Overloading ...
raldi's user avatar
  • 21.8k
129 votes
8 answers
129k views

Where do "pure virtual function call" crashes come from?

I sometimes notice programs that crash on my computer with the error: "pure virtual function call". How do these programs even compile when an object cannot be created of an abstract class?
Brian R. Bondy's user avatar
139 votes
12 answers
73k views

How are virtual functions and vtable implemented?

We all know what virtual functions are in C++, but how are they implemented at a deep level? Can the vtable be modified or even directly accessed at runtime? Does the vtable exist for all classes, ...
Brian R. Bondy's user avatar
37 votes
11 answers
24k views

Reintroducing functions in Delphi

What was the motivation for having the reintroduce keyword in the Delphi Programming Language? If you have a child class that contains a function with the same name as a virtual function in the parent ...
Frank's user avatar
  • 1,061
22 votes
6 answers
8k views

Can I prevent an inherited virtual method from being overridden in subclasses?

I have some classes layed out like this class A { public virtual void Render() { } } class B : A { public override void Render() { // Prepare the object for rendering ...
TrolleFar's user avatar
  • 950
28 votes
16 answers
8k views

Expression Evaluation and Tree Walking using polymorphism? (ala Steve Yegge)

This morning, I was reading Steve Yegge's: When Polymorphism Fails, when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon. ...
6 votes
10 answers
2k views

Inheritance and Polymorphism - Ease of use vs Purity

In a project our team is using object lists to perform mass operations on sets of data that should all be processed in a similar way. In particular, different objects would ideally act the same, ...
Cristián Romo's user avatar
52 votes
9 answers
35k views

Hiding inherited members

I'm looking for some way to effectively hide inherited members. I have a library of classes which inherit from common base classes. Some of the more recent descendant classes inherit dependency ...
MojoFilter's user avatar
  • 12.2k

15 30 50 per page
1
687 688 689 690
691