why use template?# Programming - 葵花宝典
mw
1 楼
Now i am quite confused about template
we are supposed to use it for some sort of paramiterized stuff,
template f(T)
however, if more than one classes can be fed to a certain function, they must
share certain similar properties and thus can be modeled as a hierarchy. Then
we can just define the function as f(class A) where A is the base.
Then , is template only useful in containers?
can anyone give me some corrections?
thanks lot!
we are supposed to use it for some sort of paramiterized stuff,
template
however, if more than one classes can be fed to a certain function, they must
share certain similar properties and thus can be modeled as a hierarchy. Then
we can just define the function as f(class A) where A is the base.
Then , is template only useful in containers?
can anyone give me some corrections?
thanks lot!