473,785 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

array of reference?

why can't we have array of references.
Dec 4 '07 #1
31 3232
siddhu wrote:
why can't we have array of references.
References are not objects.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 4 '07 #2
On Dec 5, 2:25 am, siddhu <siddharth....@ gmail.comwrote:
why can't we have array of references.
Reference is just an alias to the variable, no memory is allocated
for a reference. In fact, we can't have a reference to a reference or
a pointer to a reference. Hope it clarifies.
Dec 5 '07 #3
On Dec 5, 12:32 am, "Alf P. Steinbach" <al...@start.no wrote:
* siddhu:
why can't we have array of references.

A reference is not an object, it has no size.
it has a size usually equal to that of a pointer in case of usage an
argument to a none inlined function.
Dec 5 '07 #4
On Dec 5, 12:25 am, siddhu <siddharth....@ gmail.comwrote:
why can't we have array of references.
why don`t use array of const pointers?

class A * const ptrArr[size_enum];

regards,
FM.
Dec 5 '07 #5
terminator wrote:
On Dec 5, 12:32 am, "Alf P. Steinbach" <al...@start.no wrote:
>* siddhu:
>>why can't we have array of references.

A reference is not an object, it has no size.

it has a size usually equal to that of a pointer in case of usage an
argument to a none inlined function.
And when the size isn't equal to that of a pointer, what is it?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 5 '07 #6
terminator <fa***********@ gmail.comwrote in news:b2d73c27-cfd5-42ee-ae2d-
2b**********@s3 6g2000prg.googl egroups.com:
On Dec 5, 12:32 am, "Alf P. Steinbach" <al...@start.no wrote:
>* siddhu:
why can't we have array of references.

A reference is not an object, it has no size.

it has a size usually equal to that of a pointer in case of usage an
argument to a none inlined function.
No, references don't even have to have a physical representation.
Analogous to typedef, a reference only introduces a new name for an object.
It turns out that usually memory for an address is allocated for reference
parameters and reference object members, but it would be a pretty poor
compiler that allocated anything at all for a local reference.

joe
Dec 6 '07 #7
On Dec 5, 2:32 am, "Alf P. Steinbach" <al...@start.no wrote:
* siddhu:
why can't we have array of references.

A reference is not an object, it has no size.
If by size you mean storage, it is *unspecified* that they have
storage or not. So, saying they have no size would be incorrect.
Chapter and verse: 8.3.2 (4) (2007-06-25 draft). :)
Dec 6 '07 #8
Abhishek Padmanabh wrote:
On Dec 5, 2:32 am, "Alf P. Steinbach" <al...@start.no wrote:
>* siddhu:
>>why can't we have array of references.

A reference is not an object, it has no size.

If by size you mean storage, it is *unspecified* that they have
storage or not. So, saying they have no size would be incorrect.
Chapter and verse: 8.3.2 (4) (2007-06-25 draft). :)
The more proper way of answering the original question would then
be "becuase the Standard says so in [dcl.ref]/4".

However, if it's unspecified whether they have storage or not, it
usually means that in a general case they do NOT have storage, and
hence they do NOT have size.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 6 '07 #9
On Dec 5, 2:25 am, siddhu <siddharth....@ gmail.comwrote:
why can't we have array of references.
Arrays of references are not possible because they may or may not
require storage (implemented as to have size or not). In the cases
(implementation s) when they won't have a size, arrays of them won't be
possible. References are not considered as objects by the standards.
They are just aliases. In next standards revision, there might be a
reference_wrapp er added that can be used instead of plain references
wherever you need to make arrays of them or use them with standard
containers.
Dec 6 '07 #10

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

Similar topics

5
2875
by: Nico | last post by:
Hello folks, I am currently storing a set of objects inside an array, $itemlist = array(); $itemlist = new item("myitem"); //... and I am looking to develop a search function, which returns a reference to the found item.
2
2015
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 in the process that creates the reference when it is being assigned to an array element within itself. If it is already referenced, it just assigns the existing reference and avoids the problem.
12
55571
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are also removed) So far I have (val is value, ar is array, returns new array):
8
10232
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when it is assigned a text literal?? HOW can I change the array value to upper case then? What other method exists for arrays? Ex: var GridArrayName1 = new Array(); GridArrayName1 = new Array ('test-value'); GridArrayName1 = GridArrayName1...
58
10181
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of code... TCHAR myArray; DoStuff(myArray);
10
10297
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. Returning a pointer to the first element might do but I want to do what I've said. Fraser.
13
2532
by: Kevin | last post by:
Help! Why are none of these valid? var arrayName = new Array(); arrayName = new Array('alpha_val', 1); arrayName = ; I'm creating/writing the array on the server side from Perl, but I
32
6524
by: Joe Rattz | last post by:
Hmmm, I wrote the following code. I want an array of bools and I want to intialize them to false. bool bits = new bool; foreach(bool bit in bits) { bit = false; } The compiler complains on the "bit = false;" stating that bit is read-only.
16
1859
by: Frederick Gotham | last post by:
Inspired by page 219 of Nicolai M. Josuttis's book, I set out to write a class for an intrinsic array which would behave, to as far an extent as possible, like a container. Also though, I wanted no overhead whatsoever. The code I'm about to show below is not finished, it may contain the odd oversight, bug or error (but at a quick glance it seems OK). First of all though, I want to show you some macros I've written. The purpose of the...
14
20412
by: Abhi | last post by:
I wrote a function foo(int arr) and its prototype is declared as foo(int arr); I modify the values of the array in the function and the values are getting modified in the main array which is passed also. I understand that this way of passing the array is by value and if the prototype is declared as foo(int *), it is by reference in which case the value if modified in the function will get reflected in the main function as well. I dont...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9481
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10095
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9953
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8978
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.