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

前端 未结 2 1369
春和景丽
春和景丽 2021-01-27 11:01

This function is preventing Wagic: the homebrew from Compiling:

/home/white/Pandora/wagic-read-only/projects/mtg/src/GameOptions.cpp:1156: error: no match for ‘operator

相关标签:
2条回答
  • 2021-01-27 11:32
    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;
    }
    
    0 讨论(0)
  • 2021-01-27 11:53

    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.

    0 讨论(0)
提交回复
热议问题