overloaded '<<' and '>>'

Hello everybody.
I wrote a class like below:
1
2
3
4
5
6
7
8
9
10
11
class MYCLASS
{
   private:
      char Number[100];
   public:
      friend ostream& operator<<(ostream&, MYCLASS&);
      friend istream& operator>>(istream&, MYCLASS&);
      . . .
      MYCLASS& operator=(char* No);   // <-- This is important for below question
      . . .
};


My "operator<<" and "operator>>" work correctly for cin and cout.
I want to know, can I do something that take 'No' to buffer (with some classes like istream and ostream or something else) and then bring that to cin buffer?
I mean can I do something that without inputting any character from keyboard, put 'No' in cin buffer and use operator>>(istream&, MYCLASS&) function for putting it in MYCLASS object?

Thanks :-)
You mean something like:
1
2
3
std::stringstream sstr("No");
MYCLASS c;
sstr >> c;


other:

friend ostream& operator<<(ostream&, MYCLASS&);
should be
friend ostream& operator<<(ostream&, const MYCLASS&);
Can't it be done with iostream and streambuf classes?
std::stringstream is a subclass of iostream.
http://www.cplusplus.com/reference/iostream/stringstream/

I don't know what would you want to do with std::streambuf, can you explain?
http://www.cplusplus.com/reference/iostream/streambuf/
Topic archived. No new replies allowed.