[Cs3] Compile Time & Run Time
Mikhail Nesterenko
mikhail at cs.kent.edu
Sun Apr 17 23:48:54 EDT 2022
>
> Can you explain the difference between compile time and run time, as well
> giving some examples of them please?
>
If something is decided at "compile time", it means that something is
decided on the basis of the source code only, i.e. by compiler.
Compile time (early binding) of a function invocation:
BaseClass *pointer;
pointer -> function();
would determine that function() is of BaseClass. Meanwhile, the use of
polymorphic/virtual functions enables run-time (late binding)
decision as to what function() is to be invoked. Specifically, the
object that pointer points to is examined, and if it happens to belong
to a particular DerivedClass then DerivedClass::function() is
invoked. This check may not be made at the compile time since the
compiler does not know what object pointer is pointing to.
Thanks,
--
Mikhail
More information about the cs3
mailing list