Reputation: 6648
How do I go about writing a function which takes an object of a template class as a parameter? Would the following work? And can it go in the .cpp file instead of a header? (I have only written templated classes before).
template<class T> class LtdArray {
//class definition
}
template<class T> class LtdArray
bool ifBlockProcess(LtdArray <darr, string strToProc) {
//add element to LtdArray
}
Upvotes: 0
Views: 108
Reputation: 12819
When making function templates, you don't need to include the class. Your prototype should look like this:
template<class T>
bool ifBlockProcess(LtdArray<T> <darr, string strToProc);
Upvotes: 1
Reputation: 476940
Something like this should do the trick:
template<class T>
bool ifBlockProcess(LtdArray<T> & ltdarr, string strToProc)
{
//add element to LtdArray
}
Upvotes: 1