C++ Programming - References - Discussion
Discussion Forum : References - Programs (Q.No. 20)
20.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class IndiaBix
{
int x, y;
public:
IndiaBix(int &xx, int &yy)
{
x = xx;
y = yy;
Display();
}
void Display()
{
cout<< x << " " << y;
}
};
int main()
{
int x1 = 10;
int &p = x1;
int y1 = 20;
int &q = y1;
IndiaBix objBix(p, q);
return 0;
}
Discussion:
3 comments Page 1 of 1.
Ganesh maheshwari said:
7 years ago
The correct answer is A.
Because p and q are pointers they hold address and address only store by the pointer from above code we are converting the pointer into reference which is incorrect.
Because p and q are pointers they hold address and address only store by the pointer from above code we are converting the pointer into reference which is incorrect.
Shradha said:
7 years ago
Because here p & q actually containing values of x1 & y1.
Vision said:
8 years ago
Can anyone explain this?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers