No Match for 'Operator>>' in 's>>local\"

你说的曾经没有我的故事 提交于 2019-12-02 10:05:49
s >> local

Calls the default operator >> which does not understand your custom class LocalKeySym So You need to Overload the Operator >> for your custom class LocalKeySym.

An sample code:

std::istream& operator>>(std::istream& is, LocalKeySym& obj) 
{ 
  // read LocalKeySym obj from stream 

  if( /* no valid object of LocalKeySym found in stream */ )
       is.setstate(std::ios::failbit);

  return is;
}

operator >> is defined only for built-in types like, int, float, char, double etc. and it can input the address using pointers. Since your variable local is of custom type LocalKeySym. you may have to define your own operator >>.

It should be similar to overloading istream and ostream operators. See the tutorial here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!