65,209
社区成员
发帖
与我相关
我的任务
分享

/******************************************************/
//普通返回类型
string (*s1)[10];
string (*buf1())[10]
{
cout<<"This is s1!"<<endl;
return s1;
}
/******************************************************/
/*
//类型别名?这个我还写不出来,我也不知道为什么不行,我正在求助中ing...
typedef string s2[10];
using s2=string[10];
s2 *buf2()
{
cout<<"This is s2!"<<endl;
return &s2;
}
*/
/******************************************************/
//尾置返回类型
string s3[10];
auto buf3() -> string (*)[10]
{
cout<<"This is s3!"<<endl;
return &s3;
}
/******************************************************/
//decltype
string s4[10];
decltype(s4) *buf4()
{
cout<<"This is s4!"<<endl;
return &s4;
}
/******************************************************/
int main()
{
buf1();
buf3();
buf4();
return 0;
}
我先看看再说
std::array<std::string, 10> & foo(...);
std::string a [10];
auto f0 () -> std::string (&) [10];
auto f1 () -> decltype((a));

