Connecting Tech Pros Worldwide Help | Site Map

Template trouble

  #1  
Old November 1st, 2007, 03:25 AM
DerekBaker
Guest
 
Posts: n/a
What's wrong here?

template<typename Tstring Class_ini::ConvertToString(T)
{
ostringstream os;
os << T;

return os.str();
}

with T as int or bool.

Thank you
--
Derek
  #2  
Old November 1st, 2007, 04:55 AM
DerekBaker
Guest
 
Posts: n/a

re: Template trouble


* Alf P. Steinbach:
Quote:
* DerekBaker:
Quote:
>What's wrong here?
>>
>template<typename Tstring Class_ini::ConvertToString(T)
>{
> ostringstream os;
> os << T;
>>
>return os.str();
>}
>>
>with T as int or bool.
>
Try the code with 'T' replaced with 'bool'.
>
For that exercise, just remove 'template<typename T>'.
>
Cheers, & hth.,
>
- Alf
>
Adding a name after T and using that in the body was what was needed.

template<typename Tstring Class_ini::ConvertToString(T C)
{
ostringstream os;
os << C;

return os.str();
}


--
Derek
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Template trouble idar.douglas.hillgaar@gmail.com answers 6 August 6th, 2006 12:55 AM
template trouble Gernot Frisch answers 0 July 22nd, 2005 11:08 PM
template trick? Jacek Dziedzic answers 17 July 22nd, 2005 11:38 AM
Trouble specializing a member function in a template class Jeff answers 2 July 22nd, 2005 04:30 AM