1.
typedef string arrT[10];//运用typedef声明别名,arrT是一个元素类型为string的数组
using arrT=string[10];//运用using将arrT的类型声明成跟string[10]一样
arrT example(int i);//运用声明一个数组的引用,因为不能返回数组,所以只能返回指向数组的指针
2.
auto example1(int i)->int()[10];//尾置返回类型,函数返回一个指针,指针指向含有10个整型元素的数组
3.
int odd[5];
decltype(odd)example2(int i)//利用decltype关键字返回数组,decltype只负责返回odd的类型,即整型数组,但不负责把数组变成指针,左右要来表示指针
**ps:**个人为第1种更好,auto关键字会忽略顶层关键字const
const int i=0;auto m=i;这里的i的const被忽视;
而使用decltype必须要在调用函数是写多一个数组,占用空间
4.int(*example(int i))[10];//返回数组的引用,*解引用
10-25
1364
04-22
991
05-18
2922
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交