C++ Programming - References - Discussion
Discussion Forum : References - Programs (Q.No. 22)
22.
Which of the following statement is correct about the program given below?
#include<iostream.h>
int x, y;
class BixTest
{
public:
BixTest(int xx = 0, int yy = 0)
{
x = xx;
y = yy;
Display();
}
void Display()
{
cout<< x << " " << y << " ";
}
};
int main()
{
BixTest objBT(10, 20);
int &rx = x;
int &ry = y;
ry = x;
rx = y;
cout<< rx--;
return 0;
}
Discussion:
5 comments Page 1 of 1.
RazvanIacob said:
8 years ago
When you make this assignment ry=x, automatically y will be 10.
Tarun said:
8 years ago
The value of ry-- will be 9 and value of rx-- will be 19.
Jaideep Gupta said:
10 years ago
I think the answer would be 10, 20, 19.
Ayush said:
1 decade ago
Since ry has been assigned x ie it now points to variable x.
And since reference variable ry is assigned the value of x.
Hence y =x;
So answer is 10 20 10.
Am I correct?
And since reference variable ry is assigned the value of x.
Hence y =x;
So answer is 10 20 10.
Am I correct?
(1)
Rishi said:
1 decade ago
How?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers