`.' cannot appear in a constant-expression

后端 未结 4 1090
悲哀的现实
悲哀的现实 2021-01-21 23:56

I\'m getting the following error:

`.\' cannot appear in a constant-expression

for this function (line 4):

    bool Covers(const         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-22 00:16

    This is probably failing because you have not defined operator[](unsigned)const. I would also suggest that you use std::size_tor int as your loop variable; it is very uncommon to just see unsigned. Since you are using an unsigned type, though, the logical choice would be to use std::size_t. You could also try invoking this->operator[](d) instead of me[d] just as a sanity-check, although what you have should work fine assuming that your class implements the appropriate operator overload.

提交回复
热议问题