473,405 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Array of References

Hi all,
References are (almost always) implemented as constant pointers.
We can certainly have an array of constant pointers.
But then why we cannot have array of references?

I can think of atleast two places where such a thing 'might' be used,
though I am not clear whether it makes sense to have such a usage -

1) Function call
int f (int& a[]); // a is an array of integer references

2) simple definition :
void foo()
{
const int& p[] = { 2,3,4,5}; // p is an array of references to const
integers.
}
Thanks in advance,
Neelesh

Nov 4 '05 #1
2 6065
On Fri, 04 Nov 2005 08:19:11 -0800, Neelesh wrote:
References are (almost always) implemented as constant pointers.
No. Or, rather, what makes you think that, anyway?
We can certainly have an array of constant pointers.
Yes.
But then why we cannot have array of references?
Because. References are not objects, we can only have arrays of objects.
Same reason why we don't have arrays of functions.
I can think of atleast two places where such a thing 'might' be used,
though I am not clear whether it makes sense to have such a usage -
[...]


If you're not clear whether it makes sense, you should probably take
a hint from the language creators: it likely has no sense, that's why it
isn't there.

V
Nov 4 '05 #2
Neelesh wrote:
...
References are (almost always) implemented as constant pointers.
We can certainly have an array of constant pointers.
But then why we cannot have array of references?
...


The behavior of the language construct has absolutely nothing to do with the way
it is "(almost always) implemented". References in C++ represent certain
concept. And this concept, in its original form, does not include the
possibility of having arrays of references.

--
Best regards,
Andrey Tarasevich
Nov 4 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kaptain524 | last post by:
Hello, I am using PHP 5.0.4 with Apache 2, on WinXP Pro. This behavior appears to be fundamental however, and should not be affected by platform. It would seem that there is some kind of bug...
9
by: Timothy Madden | last post by:
Hello If I write a function like this void Process(double Data) { ... } it is ok, but if I try class DataProcess { double (&Data); DataProcess(double Data)
10
by: Fraser Ross | last post by:
I need to know the syntax for writing a reference of an array. I haven't seen it done often. I have a class with a member array and I want a member function to return an reference to it. ...
2
by: BrianP | last post by:
Hi, I have had to invent a work-around to get past what looks like a JavaScript bug, the malfunctioning Perl-like JavaScript array functions including SPLICE() and UNSHIFT(). I have boiled it...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
4
by: None | last post by:
Hi, I have declared array as Int ids = new int; In ArrayList we can remove specified index using RemoveAt(5) method. My question is how can we do this one with int array (single dimensional...
7
by: heddy | last post by:
I have an array of objects. When I use Array.Resize<T>(ref Object,int Newsize); and the newsize is smaller then what the array was previously, are the resources allocated to the objects that are...
11
by: rayreeves | last post by:
How do I declare an array of references to the elements of an array of values? Ray
2
by: subramanian100in | last post by:
From http://groups.google.com/group/comp.lang.c++/browse_frm/thread/d5da6e5e37fd194d/6e2e8424a1cfbd2b#6e2e8424a1cfbd2b the following portion is taken. "Mike Wahler"...
31
by: siddhu | last post by:
why can't we have array of references.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.