View Single Post
Old 08-23-2007, 11:57 AM   #1 (permalink)
destin
Java Junkie
 
destin's Avatar
 
Join Date: Mar 2005
Posts: 40
destin is on a distinguished road
Functions that accept all types?

In C++, is it possible to have a function that accepts all types?

Basically, I want to override the left-shift operator so that I can do the following.
Code:
myVar << a << b << moreStuff << "blah" << endl;
Is there a way I can accomplish this so that I don't have to override dozens of operator functions?

I would like to do something like this:
Code:
MyClass& MyClass::operator<<(??? var)
{
  stringstream stream;
  stream << var;
  // do something with stream.str()
  return *this;
}
Thanks in advance.
destin is offline   Reply With Quote