T
trubar a
hi
1) One definition of binding is that it is the act of replacing
function names with memory addresses.
a) Thus I assume early binding means function calls are replaced with
memory addresses during compilation process, while with late binding
this replacement happens during runtime?
b) Why are virtual methods also considered early bound (thus the
target method is found at compile time, and code is created that will
call this method)? As far as I know, with virtual methods the call to
actual method is resolved only during runtime and not compile time?!
2) Assume:
• B1 defines methods virtualM() and nonvirtualM(), where former method
is virtual while the latter is non-virtual
• B2 derives from B1
• B2 overrides virtualM()
• B2 is defined inside assembly A
• Application app doesn’t have a reference to assembly A
In the following code application app dynamically loads an assembly A,
creates an instance of a type B2 and calls methods virtualM() and
nonvirtualM():
Assembly a = Assembly.Load( “A” );
Type t= a.GetType ( “B2” );
B1 a = ( B1 ) Activator.CreateInstance ( “t” );
a.virtualM();
a.nonvirtualM();
a) Is call to a.virtualM() considered early binding or late binding?
b) I assume a call to a.nonvirtualM() is resolved during compilation
time?
3) Does the term late binding refer only to looking up the target
method at run time or does it also refer to creating an instance of
given type at runtime?
thanx
1) One definition of binding is that it is the act of replacing
function names with memory addresses.
a) Thus I assume early binding means function calls are replaced with
memory addresses during compilation process, while with late binding
this replacement happens during runtime?
b) Why are virtual methods also considered early bound (thus the
target method is found at compile time, and code is created that will
call this method)? As far as I know, with virtual methods the call to
actual method is resolved only during runtime and not compile time?!
2) Assume:
• B1 defines methods virtualM() and nonvirtualM(), where former method
is virtual while the latter is non-virtual
• B2 derives from B1
• B2 overrides virtualM()
• B2 is defined inside assembly A
• Application app doesn’t have a reference to assembly A
In the following code application app dynamically loads an assembly A,
creates an instance of a type B2 and calls methods virtualM() and
nonvirtualM():
Assembly a = Assembly.Load( “A” );
Type t= a.GetType ( “B2” );
B1 a = ( B1 ) Activator.CreateInstance ( “t” );
a.virtualM();
a.nonvirtualM();
a) Is call to a.virtualM() considered early binding or late binding?
b) I assume a call to a.nonvirtualM() is resolved during compilation
time?
3) Does the term late binding refer only to looking up the target
method at run time or does it also refer to creating an instance of
given type at runtime?
thanx