- #include <iostream>
- #include <sstream>
- using namespace std;
- class two
- {
- public:
- bool operator==(const char& right)
- {
- return (ch == right);
- }
- friend ostream& operator<<(ostream& os,const two& right)
- {
- return os << right.ch;
- }
- friend istream& operator>>(istream& is,two& right)
- {
- return is >> right.ch;
- }
- private:
- char ch;
- };
- int main()
- {
- two t;
- bool flag = true;
- stringstream stream("hello world");
- while (stream >> t)
- {
- cout << t;
- if ((t == 'o') && (flag == true))
- {
- cout << " ";
- flag = false;
- }
- }
- return 0;
- }