[語法] 回傳一個二維陣列
雖然return 一個local的array是不對的
但是我想知道為什麼 compile不給我過@@
以下是code:
void Q(int (*a)[3])
{
cout<<*(a[1])<<endl;
cout<<a[0][0]<<endl;
}
(int*)[3] QQ()
{
int b[][3]={{1,2,3},{4,5,6},{7,8,9},{10,11,12}};
return b;
}
int main()
{
int a[][3]={{1,2,3},{4,5,6},{7,8,9},{10,11,12}};
Q(a);
}
Q這樣的prototype 是OK的 傳入一個二維陣列
但是我想依樣 return 的型態也寫成 跟Q傳入的一樣
但是怎麼寫就是不給我過~
原因不明= =
請教各位
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.207.187
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章