C++ Programming - References - Discussion

Discussion :: References - General Questions (Q.No.4)

4. 

Which of the following statements is correct?

  1. Change a reference changes the referent.
  2. We can create an array of references.

[A]. Only 1 is correct.
[B]. Only 2 is correct.
[C]. Both 1 and 2 are correct.
[D]. Both 1 and 2 are incorrect.

Answer: Option A

Explanation:

No answer description available for this question.

Anita said: (Aug 25, 2013)  
When there will be any change in reference then referent get automatically changed.

Krishan Gopal said: (Sep 25, 2013)  
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];
}

Krishna Gopal said: (Sep 27, 2013)  
I apology for my previous comment array of reference is not possible but reference to array is possible.

Ramd said: (Oct 29, 2014)  
@Krish.

Don't you think the program that you have created is for reference to array?

Madhuri said: (Jul 10, 2017)  
It is very useful for me. Thank you all.

Vishal said: (Sep 27, 2018)  
Hi please give an explanation about reference given in the sentence.

Shubham said: (Feb 27, 2019)  
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.

Gowtham said: (Apr 10, 2019)  
What is meant by referent?

Suraj Pawar said: (Sep 7, 2019)  
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.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.