C++ 连接不同的运算符

C++ 连接不同的运算符,c++,operator-overloading,operator-keyword,operator-precedence,C++,Operator Overloading,Operator Keyword,Operator Precedence,我正在尝试实现一个支持使用不同运算符连接的类: class MyClass { public: template<typename T> MyClass &operator<<(const T& val ) { //do something with val return *this; } template<typename T> MyClass &operator=(const T& val) { //do s

我正在尝试实现一个支持使用不同运算符连接的类:

class MyClass {
public:

template<typename T>
MyClass &operator<<(const T& val ) {
  //do something with val
  return *this;
}

template<typename T>
MyClass &operator=(const T& val) {
  //do something with val
  return *this;
} 

};

int main() {
  MyClass a;
  a << "hallo" = 3 << "huuh"; //compiler will complain about 
}
我错过什么了吗

非常感谢你的帮助

由于,表达式

a << "hallo" = 3 << "huuh";
被评估为

(a << "hallo") = (3 << "huuh");
您的编译器正在抱怨由于表达式而缺少有效的运算符

a << "hallo" = 3 << "huuh";
被评估为

(a << "hallo") = (3 << "huuh");
而您的编译器正在抱怨缺少有效的运算符