您的位置:首页 > 编程语言 > C语言/C++

auto

2014-03-08 21:12 281 查看
• auto is used to infer the type of the variable that is being declared and initialized

• In ‘old’ C++:


  


• In C++ 11:


    


• Anyway,there are restrictions on its usage:

• You cannot use auto as a type of an argument of a function or method.

• Your method return type cannot be auto

• You cannot use auto to declare and initialize variables of several types in the same line, like this:  

  autox = 2, b = true, c = "hello"; //invalid auto usage
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c++11 auto