Suppose that we have two classes, A and B. B derives from A and redefines the implementation of a 9L0-509 method c() that resides in class A. Now suppose that we have an object b of class B. How should the instruction b.c() be interpreted?
If b is declared in the stack (not declared as a pointer or a reference) the compiler applies static binding, 9L0-402 Questions this means it interprets (at compile time) that we refer to the implementation of c() that resides in B.
However, if we declare b as a pointer or a reference of class A, the compiler could not know which 9L0-509 method to call at compile time, because b can be of type A or B. If this is resolved at run time, the method that resides in B will be called. This is called dynamic binding. If this is resolved at compile time, the method that resides in A will be called. This is again, static binding.
virtual functions are an essential part of designing a class hierarchy and sub-classing Apple 9L0-402 classes from a toolkit. The concept is relatively simple, but often misunderstood. Specifically it determines the behavior of overridden methods in certain contexts.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment