Not sure I understand you.
An object is declared with a type. The caller can use any methods or
properties that are intrinsic to that type. If a derived type is provided,
the calling code cannot see the methods of the derived type without casting
the datatype.
Therefore:
class A
{
void ABC() { // something useful }
}
class B : A
{
void XYZ() { // something else }
}
class C
{
A myA;
B myB = new (B);
myB.XYZ(); // this is valid
myA = myB; // this is valid
myA.XYZ(); // this is not valid, since type A has no knowledge of the
XYZ method.
}
Many design patterns rely on the ability of an interface to represent a
contract that can be extended, but that the calling application may not need
to know about the derived classes. This is called the Liskov Substitution
Principle.
See
http://www.objectmentor.com/resources/articles/lsp.pdf
for details.
Hope this helps.
--- Nick
"Bharat Sharma" <bh****@ten-technologies.com> wrote in message
news:1e*****************************@phx.gbl...
Hello All Wise Persons.
I don't know wheather my question is okay or i need to
revisit my OOP fundamentals. AS we have read till now in
OOP that Every Parent Class can see and execute the
Methodas of the object it points to (be it the object of
self or the derived class). However in case of .NET and
Java for that matter, All objects are derived from
System.Object which lets them execute the methods at run-
time i.e. Late Binding. So how come this is happening.
Please clear my doubt or else provide me a good link to re-
visit OOP Fundamentals.
Thank You,
Bharat Sharma.