C++ 将我自己的字符串类与<&书信电报;操作人员

C++ 将我自己的字符串类与<&书信电报;操作人员,c++,string,operator-overloading,ostream,C++,String,Operator Overloading,Ostream,我正在寻找一种方法,在自定义字符串类中使用ostream,并重载操作符不是问题。定义您的类,并在其定义中添加ostream&operator它有这么简单吗?但是我的字符串输出到的ostream不处理std::strings吗?或者我只是忽略了这一点,在操作符定义中进行“打印”?感谢ostream是cout的类型;它与std::string没有关系。我的声明允许您在 MyStringClass string MyOutput << "hello" << string <

我正在寻找一种方法,在自定义字符串类中使用ostream,并重载操作符不是问题。定义您的类,并在其定义中添加
ostream&operator它有这么简单吗?但是我的字符串输出到的ostream不处理std::strings吗?或者我只是忽略了这一点,在操作符定义中进行“打印”?感谢
ostream
cout
的类型;它与std::string没有关系。我的声明允许您在

MyStringClass string
MyOutput << "hello" << string << "World" << std::endl;