作者layan (一定要喝温开水!!!)
看板C_and_CPP
标题Re: [问题] 原来这样写是没意义的
时间Thu Apr 23 14:59:28 2009
※ 引述《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