其他分享
首页 > 其他分享> > auto关键字

auto关键字

作者:互联网

c++

不指定变量的类型,由编译器根据变量的初始值确定。

auto a = 0; // a is int
auto b = 0.0; // b is double
auto c = 0L; // c is long
auto d = 'a'; // d is char

c

明示变量为自动存储类型主要目的是表明使用一个与外部变量同名的变量。

int ex_var = 10;
void fun()
{
  auto int ex_var = 11; // ex_evar 与 外部变量同名
}

标签:变量,int,auto,同名,关键字,ex,var
来源: https://www.cnblogs.com/baiyutang7/p/16366396.html