C++ Programming - References - Discussion
Discussion Forum : References - General Questions (Q.No. 4)
4.
Which of the following statements is correct?
- Change a reference changes the referent.
- We can create an array of references.
Discussion:
11 comments Page 1 of 2.
ANITA said:
1 decade ago
When there will be any change in reference then referent get automatically changed.
Krishan gopal said:
1 decade ago
But we can create array of reference also. Given below,
int arr1[3];
int(&arr2)[3]=arr1;
for(int index=0;index<3;++index)
{
cout<<arr2[3];
}
int arr1[3];
int(&arr2)[3]=arr1;
for(int index=0;index<3;++index)
{
cout<<arr2[3];
}
Krishna gopal said:
1 decade ago
I apology for my previous comment array of reference is not possible but reference to array is possible.
RamD said:
1 decade ago
@Krish.
Don't you think the program that you have created is for reference to array?
Don't you think the program that you have created is for reference to array?
Madhuri said:
8 years ago
It is very useful for me. Thank you all.
Vishal said:
7 years ago
Hi please give an explanation about reference given in the sentence.
Shubham said:
7 years ago
int arr1[3] = {0,1,2};
int (&arr2)[3] = arr1;
for (int index = 0; index<3; ++index)
{
cout << arr2[index];
}
Here, arr2 is referring to arr1.
int (&arr2)[3] = arr1;
for (int index = 0; index<3; ++index)
{
cout << arr2[index];
}
Here, arr2 is referring to arr1.
(1)
Gowtham said:
6 years ago
What is meant by referent?
Suraj Pawar said:
6 years ago
In my opinion, the array of reference is not possible since.
You need a base address for the array. That means it will be illegal since references are only just another name for a variable, no addresses.
You need a base address for the array. That means it will be illegal since references are only just another name for a variable, no addresses.
(1)
Dips said:
3 years ago
It is very useful for me. Thank you all.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers