Re: [問題] 原來這樣寫是沒意義的
※ 引述《QQ29 (我愛阿蓉)》之銘言:
: new的應該不可能 我在想 靜態的array 傳給副程式應該是有辦法取得長度吧???
: 請各位給點指教thx~~
可以做的到, use template
template <class Type, int Size>
void init(Type (&array)[Size])
{
cout << sizeof(array) << endl;
}
int main()
{
double array[20];
cout << sizeof(array) << endl;
init(array);
}
both of the output are 160. XDXD
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 139.175.68.252
討論串 (同標題文章)