Change it to std::cout<< stu::no() << std::endl;
Without the ()
, I believe it's evaluating as a pointer, and not doing what you're expecting.
Edit: As pointed out by @Loomchild, using g++ -Wall
will provide further insight as to why it's always 1. The pointer to the static function is always evaluated as true
in this context, hence the value being printed.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…