hi
i want get to function parmter like streamstring
// Declartion foo (std::stringstream strString);
// Using foo("Hello" << "world");
how to do that??
hi
i want get to function parmter like streamstring
// Declartion foo (std::stringstream strString);
// Using foo("Hello" << "world");
how to do that??
The << syntax used for stream insertion is achieved by the various stream classes overloading the left-shift operator (that's what the << is). You can overload the left shift operator for your class:
struct Example
{
Example& operator<<(int i)
{
/* use i */
return *this;
}
};
Example e;
e << 42; // calls operator<< overload
You can do it with a macro - see this answer http://stackoverflow.com/questions/3027729/i-want-to-trace-logs-using-a-macro-multi-parameter-always-null-problem-c-windo/3027897#3027897