How to pass default arguments in template classes in C++?

Default arguments can be passed to a generic class. It is useful for writing programs where no explicit values are specified.

For Example:

template <class T=int, int x=10> class test {

T a[x];


test() {

register int b;

for(b=0; b<x; b++) a[b] = b;


Leave a Reply