Template trouble

D

DerekBaker

What's wrong here?

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

return os.str();
}

with T as int or bool.

Thank you
 
A

Alf P. Steinbach

* DerekBaker:
What's wrong here?

template<typename T> string 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
 
D

DerekBaker

* Alf P. Steinbach:
* DerekBaker:

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 T> string Class_ini::ConvertToString(T C)
{
ostringstream os;
os << C;

return os.str();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,197
Messages
2,571,040
Members
47,635
Latest member
SkyePurves

Latest Threads

Top