Definitions

Static typing means determining the exact type of a variable when the program is compiled. It is the default typing mechanism in C++. Note that this has no particular relation to the keyword static.

Dynamic typing means delaying the determination of the exact type of a variable until run time rather than fixing that type at compile time, as in static typing.

Polymorphism, one of the major organizing principles in C++, allows us to implement several classes with the same interface and treat objects of all these classes as though they were of the same class. Polymorphism is a variety of dynamic typing that maintains the safety factor of static type-checking, because the compiler can determine at compile time whether a function call is legal even if it does not know the exact type of the object that will receive that function call at run time. Polymorphism is derived from the Greek poly, meaning “many”, and morph, meaning “form”. In other words, the same behavior is implemented in different forms.

Declaring a function to be virtual means that it is a member of a set of functions having the same signatures and belonging to classes related by inheritance. The actual function to be executed as the result of a given virtual function call is selected from this set of functions dynamically (i.e., at run time) based on the actual type of an object referred to via a base class pointer (or base class reference). This is the C++ dynamic typing mechanism used to implement polymorphism, in contrast to the static typing used for non-virtual functions, which are selected at compile time.

Reference counting is a mechanism that allows one copy of an object to be shared among a number of users while arranging for the automatic disposal of that object as soon as no one is using it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset