Is C++11 auto type dangerous? [duplicate]

妖精的绣舞 提交于 2019-12-06 10:51:19

My personal experience is auto is handy for generic code, or things like range-based for loop, but you might get something like

auto count = getCount();
if (count < 0) {
  // do something
}

If getCount() returns an unsigned number, instead of what you might be expecting (int), you won't even get a warning.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!