Here is my code:
template<class T> void ToString(T &var, string &rhs)
{
I made a simple template function which I thought would do a nice integer or any applicable variable to string conversion. When I call it:
int main(int argc, char *argv[])
{
The output is
The day is
What am I doing wrong?
template<class T> void ToString(T &var, string &rhs)
{
stringstream conv;
conv << var;
conv.str(rhs);
};I made a simple template function which I thought would do a nice integer or any applicable variable to string conversion. When I call it:
int main(int argc, char *argv[])
{
string buffer;
int Day(0);
ToString<int>(Day,buffer);
cout << "The day is " << buffer;
return 0;
}cout << "The day is " << buffer;
return 0;
The output is
The day is
What am I doing wrong?