我无法让枚举类运算符工作

时间:2018-08-17 17:52:14

标签: c++ c++11

我得到一个错误

  

FastOut<NMAX>::Flags FastOut<NMAX>::operator&(FastOut<NMAX>::Flags, FastOut<NMAX>::Flags)必须接受零或一个参数

template<int NMAX>
class FastOut{
enum class Flags;
protected:
    char buffer[NMAX];
    std::map<Flags,bool>FM={(UP,0),(LOW,0),(BOOL,0)};
public:
    enum class Flags{upper,lower,boolapha };
    friend  Flags operator&(Flags a,Flags b);
    FastOut();
    FastOut(const char *);
    FastOut(const std::string&);
    FastOut & operator << (int);
    FastOut & operator << (char);
    FastOut & operator << (long long);
    FastOut & operator << (float);
    FastOut & operator << (double);
    FastOut & operator << (char *);
    FastOut & operator << (const std::string &);
    FastOut & operator << (const FastOut&);
    void open(const char*);
    void open(const std::string&);
    void flush();
    void clear();
    ~FastOut();
};
template<int NMAX>
typename FastOut<NMAX>::Flags FastOut<NMAX>::operator&(Flags a,Flags b){

}

我想说FasOut<N>::Flags a= FastOut<N>::Flags::upper | FastOut<N>::Flags::lower

1 个答案:

答案 0 :(得分:0)

二元运算符 member 应该只接受一个参数,即右手参数–左手参数为*this

template<int NMAX>
typename FastOut<NMAX>::Flags FastOut<NMAX>::operator&(Flags rhs) const
{
    // Return *this & rhs
}