References and arrays

王朝other·作者佚名  2008-06-01
宽屏版  字体: |||超大  

PROBLEM: ajackson@keck.tamu.edu (Andrew J. Jackson)

I'm inquiring on how to declare a reference to an array of integers

RESPONS: Efim Birger (efim@microware.com)

try this:

typedef int *intp;

int arr[10];

intp& aaa = arr;

RESPONSE: fjh@munta.cs.mu.OZ.AU (Fergus Henderson), 11 Aug 94

This code is illegal. `aaa' is a (non-const) reference to a pointer to int.

`arr' is an array of int, which will be converted to a pointer to int.

The result of that conversion is a temporary.

You are initializing a non-const reference with a temporary, which is illegal.

RESPONSE: admin@rzaix13.uni-hamburg.de (Bernd Eggink)

There is no sUCh thing as a reference to an array.

RESPONSE: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)

There most certainly is.

(An array of references is illegal, but a reference to an array is quite OK.)

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有