tips~2:auto

1.C++11中引入的类型说明符,用它可以让编译器去分析所属类型;且auto定义的变量必须有初始值

1 auto i=0,*p = &i;//正确
2 auto i;//错误,没有初始化;

2.auto 会忽略掉顶层const,保留底层const;

1 const int a =1;
2 auto b=a;//b是int型

3.如果想保留顶层const

const auto b = a;

猜你喜欢

转载自www.cnblogs.com/xuanxuanbk/p/10631362.html
今日推荐