首页 > 代码库 > C++ operator bool

C++ operator bool

雕虫小技:

#include <iostream>struct A{    operator bool(){        return false;    }};int main(){    A a{};    if(!a){        std::cout<<"1";    }}

还记得当年大明河畔的夏老板吗?

ifstream in(..);if(!in){..}

 

C++ operator bool