c++ convert class to boolean

前端 未结 5 1354
既然无缘
既然无缘 2020-12-14 16:12

With all of the fundamental types of C++, one can simply query:

if(varname)

and the type is converted to a boolean for evaluation. Is there

5条回答
  •  长情又很酷
    2020-12-14 16:41

    C++ checks if the statements result is whether equal to zero nor not. So i think you can define equality operator for your class and define how your class will be different from zero in which conditions.

提交回复
热议问题