tags:

views:

57

answers:

2

hi

i want get to function parmter like streamstring

// Declartion foo (std::stringstream strString);

// Using foo("Hello" << "world");

how to do that??

+2  A: 

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
James McNellis