C++ 任何人都知道什么是'cimg::exception_mode()=0;`做
以前从未见过这种语法。异常模式可能返回一个引用,并将其设置为0。例如:C++ 任何人都知道什么是'cimg::exception_mode()=0;`做,c++,C++,以前从未见过这种语法。异常模式可能返回一个引用,并将其设置为0。例如: const unsigned int omode = cimg::exception_mode(); cimg::exception_mode() = 0; 因此,第二行相当于: unsigned int& exception_mode() { return mode; }; 顺便说一句,它真的很难看!我会尽量避免这种语法。函数可能返回对int的引用 void set_exception_mode( ui
const unsigned int omode = cimg::exception_mode();
cimg::exception_mode() = 0;
因此,第二行相当于:
unsigned int& exception_mode() { return mode; };
顺便说一句,它真的很难看!我会尽量避免这种语法。函数可能返回对
int
的引用
void set_exception_mode( uint v ) { mode = v; };
这允许返回的内容作为l值。在这种情况下,它将引用的int
设置为零
unsigned int exceptionMode; // Declared somewhere
// ...
unsigned int& cimg::exception_mode() { return exceptionMode; }
// ...
cimg::exception_mode() = 0; // Equivalent to exceptionMode = 0;