什么是`auto`用于之前? [英] What was `auto` used for before?

查看:143
本文介绍了什么是`auto`用于之前?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在C ++ 11之前, auto 关键字具有完全不同的含义;它是一个存储类型说明符,指示具有自动存储类型(即放置在堆栈上)的对象。

I know that before C++11 the auto keyword had a completely different meaning; it was a storage type specifier indicating an object that has automatic storage type (ie, placed on the stack).

这是理论如何...你实际上使用这个关键字(语法),为什么?此外,我没有看到这个关键字在实际代码pre-C ++ 11;

That's how the theory goes... How would you actually use this keyword (syntax), and why? Also, I haven't seen this keyword in actual code pre-C++11; when was it useful (what time period)?

推荐答案

它用于声明一个具有自动存储持续时间的局部变量(即, on the stack)。

It was used to declare a local variable with automatic storage duration (i.e., "on the stack").

至少自从C90以来它是一个无用的关键字,因为自动存储持续时间是局部变量的默认存储持续时间。

At least since C90 it has been a useless keyword, since automatic storage duration is the default storage duration for a local variable.

这篇关于什么是`auto`用于之前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆