Dynamic binding (aka dynamic dispatch) is the process of mapping a message to a specific piece of code (method) at runtime.
Questions tagged [dynamic-binding]
257 questions
4
votes
3 answers
Difference between Static binding and Dynamic binding of Array
I've just read through all the search result about the same topic I'm asking right now in stackoverflow and it's not really answer my curiosity.But here's the thing.
The Question
1.)From what i know , static binding means it's set during compile…

caramel1995
- 2,968
- 10
- 44
- 57
4
votes
3 answers
Static type of the exception object
I read the following from C++ Primer (5th edition, Section 18.1.1):
"When we throw an expression, the static, compile-time type of that expression determines the type of the exception object." So I tried the following code:
#include…

yuanlu0210
- 193
- 6
4
votes
1 answer
Difference calling virtual through named member versus address or reference
Updated below: In clang, using an lvalue of a polymorphic object through its name does not activate virtual dispatch, but it does through its address.
For the following base class B and derived D, virtual function something, union Space
#include…

TheCppZoo
- 1,219
- 7
- 12
4
votes
2 answers
Why and how can an object file of old code use new code that uses the generic programming paradigm even though templates are static binding?
This is an entirely different question than the one I asked before which is why I'm posting this.
I would like to define my topic to be a subjective question that inspires answers which explain "why" and "how". This is allowed according to the Help…

Wandering Fool
- 2,170
- 3
- 18
- 48
4
votes
2 answers
Dynamic binding of private methods: Java vs. C++
This is not allowed in Java:
class A {
public void method() {}
}
class B extends A {
private void method() {}
}
It generates a compile error:
error: method() in B cannot override method() in A
attempting to assign weaker access…

Robz
- 1,747
- 5
- 21
- 35
4
votes
2 answers
Objective-C uses dynamic binding, but how?
I know that Objective-C uses dynamic binding for all method calls. How is this implemented? Does objective-c "turn into C code" before compilation and just use (void*) pointers for everything?

bobobobo
- 64,917
- 62
- 258
- 363
3
votes
2 answers
Dynamic Binding Example in C++
This piece of code is a classical example of dynamic binding in Objective-C
[1]:
float total = tareWeight; // start with weight of empty container
int i, n = [self size]; // n = number of members
for (i = 0; i < n; ++i) { // loop over…

sidyll
- 57,726
- 14
- 108
- 151
3
votes
1 answer
Still confused about Objective-C's dynamic binding
The question is from a comment I just added to the answer to this question, but it shouldn't be a duplicate.
The answer from @Bavarious to that question makes sense to me, but I am still confused why the runtime can not bind the method to the right…

neevek
- 11,760
- 8
- 55
- 73
3
votes
1 answer
Can I call an overridden method from the super of the super?
Assume that I have these three classes:
class Foo {
void fn() {
System.out.println("fn in Foo");
}
}
class Mid extends Foo {
void fn() {
System.out.println("fn in Mid");
}
}
class Bar extends Mid {
void fn() {
…

Sleiman Jneidi
- 22,907
- 14
- 56
- 77
3
votes
2 answers
Stuck in understanding dynamic binding in Objective-c
I have just started learning Objective-C, I am reading Programming in Objective-C 3rd Edition by Stephen G. Kochan.
There's a paragraph explaining the polymorphism mechanism:
At runtime, the Objective-C runtime system will check the actual class of…

neevek
- 11,760
- 8
- 55
- 73
3
votes
1 answer
Virtual function calling a non-virtual function and vice versa
I have a class A as a base class of class B.
I have called the non-virtual function, abc(), within my virtual function, xyz(), as mentioned below.
Due to run-time polymorphism, B:xyz is called – I understand this.
However, I don't understand, why…

Sumaiya A
- 137
- 1
- 14
3
votes
3 answers
Why the method that gets the Father class as a parameter is called and not the method that gets the child class as a parameter?
I have a class named A, and a class named B that extends A.
Playing with some methods to understand polymorphic behaviour, I ran into a weird situation.
public class Main {
public static void main(String[] args){
B b = new B();
A…

Ronen Hanukayev
- 53
- 5
3
votes
2 answers
how is the connection between signal and slot made in QT?
I have been a Qt programmer for quite some time now and i understand most of the general features of Qt. I am still confused about how the connect statement connects a signals to a slot at run time. Basically i would like to understand what happens…

maxpayne
- 2,479
- 4
- 28
- 28
3
votes
3 answers
Does RTTI mean Dynamic Binding?
In C++, does Run-Time Type Information (RTTI) mean dynamic binding?

Josh Morrison
- 7,488
- 25
- 67
- 86
3
votes
5 answers
Is there anything static about python function / method invocations?
In asking a question about reflection I asked:
Nice answer. But there is a difference between saying myobject.foo() and x = getattr(myobject, "foo"); x();. Even if it is only cosmetic. In the first the foo() is compiled in statically. In the…

Joe
- 46,419
- 33
- 155
- 245