explicit operator bool error

后端 未结 2 2278
甜味超标
甜味超标 2021-01-11 15:15

I get the Compiler Error C2071 when I try to implement the explicit operator bool:

class C
{
public:

    explicit operator bool() const
    {
          


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-11 15:38

    Visual Studio 2012 does not support explicit conversion operators, see C++11 Features in Visual C++ 11.

    These articles talk about the safe bool idiom:

    • http://www.artima.com/cppsource/safebool.html
    • http://en.wikibooks.org/wiki/More_C++_Idioms/Safe_bool

提交回复
热议问题