Sunday, July 1, 2007

understand implicit interfaces and compile time polymorphism

oops revolves around explicit interfaces and runtime polymorphism

in template programming implicit interface and compile time polymorphism move to the fore.

basically the point is that the interface that a template class must support is defined by the operations and function calls that has been made on the object instantiated from it.

so if their is a template class and two different fns are involed on two different instantiations then do both types need definition of that kind of object ?a1.f00() , a2.foo1() ---- does this mean a1.foo1() also has to be defined ?? ..not sure if this quesiton makes sense

things to remember:
both classes and templates support interfaces and polymorphism
for classes interfaces are explicit and centered on function signatures, polymorphism occurs at runtime through virtual functions
for template parameters interfaces are implicit and based on valid expressions polymorphism occurs during compilation through template instantiation, and function overloading resolution.

No comments: