An odd C++ error: test.cpp:15: error: passing ‘const *’ as ‘this’ argument of ‘*’ discards qualifiers

前端 未结 5 732
闹比i
闹比i 2020-12-23 21:13

I\'m having some trouble with a particular piece of code, if anyone can enlighten me on this matter it would be greatly appreciated, I\'ve isolated the problem down in the f

5条回答
  •  死守一世寂寞
    2020-12-23 21:58

    The line: test2.test()

    is calling a non const function, even though test2 is a const reference. That's the problem. You can fix this by making testing::test a const function.

提交回复
热议问题