warning C4172: returning address of local variable or temporary 代码如下: CMgr& CMgr::instance(){ CMgr _mgr; //不要忘记static return _mgr;}
如果上述代码中无static 则会提示警告。 将来会产生非常大的麻烦。
本文探讨了C++中返回局部变量地址所引发的warning C4172,并给出了解决方案。若未使用static修饰符,则可能导致运行时错误。
warning C4172: returning address of local variable or temporary 代码如下: CMgr& CMgr::instance(){ CMgr _mgr; //不要忘记static return _mgr;}
如果上述代码中无static 则会提示警告。 将来会产生非常大的麻烦。
1934
966

被折叠的 条评论
为什么被折叠?