GENERIC SUBPROGRAMS
- A generic subprograms is a subprogram which have parametric polymorphism.
- A generic subprogram can accept different types of values of same single memory location.
- Parametrically polymorphic subprograms are often called generic subprograms.
- C++ provide a kind of compile-time parametric polymorphism.
For example Generic Functions in C++:
template <class Type>
void show(Type a) {
cout<<a;
}
void main()
{
show(10);
show(10.2);
show(‘c’);
}
References:
- Sebesta,”Concept of programming Language”, Pearson Edu
- Louden, “Programming Languages: Principles & Practices” , Cengage Learning
- Tucker, “Programming Languages: Principles and paradigms “, Tata McGraw –Hill.
- E Horowitz, “Programming Languages”, 2nd Edition, Addison Wesley