Monday, July 02, 2012

.Net: Instantiating



When instantiating classes, the class which is on the left side of the equation is called the declarative class and the class which is on the right side is called the instantiating class.

































Base class called "Animal" contains 2 methods as

public void Eat()
public void Sleep()



Sub class called "Lion" which derived from "Animal" contains 2 new methods as
public void Hunt()
public void Walk()
















When instantiating with base class as the declarative class and the derived class as the instantiating class, what will be structure of the instance? You'll see it carried 2 public methods of the base class. Actually this instance will carry all the methods, properties and variables from base class (according to encapsulation and other object oriented principles). This will not relevant if you override or shadow the base class methods.

No comments:

Post a Comment