C++ Programming - References - Discussion
Discussion Forum : References - General Questions (Q.No. 9)
9.
Which of the following statements is correct?
- An array of references is acceptable.
- We can also create a reference to a reference.
Discussion:
13 comments Page 2 of 2.
Pooja said:
6 years ago
No, we can also create a reference to reference but we cannot create an array of references.
(1)
Prathamesh mukkawar said:
5 years ago
According to me;
The possible one is;
#include<iostream>
using namespace std;
int main()
{
int i = 11;
int &j = i;
int &k = j;
cout<<"i = "<<i<<endl;//11
cout<<"j = "<<j<<endl;//11
cout<<"k ="<<k<<endl;//11
return 0;
}
The possible one is;
#include<iostream>
using namespace std;
int main()
{
int i = 11;
int &j = i;
int &k = j;
cout<<"i = "<<i<<endl;//11
cout<<"j = "<<j<<endl;//11
cout<<"k ="<<k<<endl;//11
return 0;
}
Ajit Kumar Sharma said:
1 year ago
@All.
In C++, I checked the above two different statements for representing the way to write the reference to reference in this discussion page . And complied it both statements. Both giving me the same results and working fine to run.
For example, int x = 4;
i.e , (1) int &(&y) = x; // correct and run without error.
(2) int x= 4;
int& y = x;
int& z = y; // correct and run without error.
Note : 'x' variable in both statements is already declared as lvalue.
In C++, I checked the above two different statements for representing the way to write the reference to reference in this discussion page . And complied it both statements. Both giving me the same results and working fine to run.
For example, int x = 4;
i.e , (1) int &(&y) = x; // correct and run without error.
(2) int x= 4;
int& y = x;
int& z = y; // correct and run without error.
Note : 'x' variable in both statements is already declared as lvalue.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers