C++ Programming - References - Discussion
Discussion Forum : References - Programs (Q.No. 21)
21.
Which of the following statement is correct about the program given below?
#include<iostream.h>
int i, j;
class IndiaBix
{
public:
IndiaBix(int x = 0, int y = 0)
{
i = x;
j = x;
Display();
}
void Display()
{
cout<< j <<" ";
}
};
int main()
{
IndiaBix objBix(10, 20);
int &s = i;
int &z = j;
i++;
cout<< s-- << " " << ++z;
return 0;
}
Discussion:
4 comments Page 1 of 1.
Amit said:
10 years ago
Please explain it to me. I can't get it.
(1)
Somebody said:
9 years ago
Yeah! someone explain it.
(1)
Venkat said:
9 years ago
Parameterised constructor is invoked, in that j=x ; i.e., j=10 will assign (here j is global)
j= 10 will be printed by calling display().
int &s = i; // i=10
int &z = j; // j=10 (here j is global, value of j is 10
i++; // 11
cout<< s-- << " " << ++z; // 11 11
j= 10 will be printed by calling display().
int &s = i; // i=10
int &z = j; // j=10 (here j is global, value of j is 10
i++; // 11
cout<< s-- << " " << ++z; // 11 11
Pkc said:
9 years ago
Values of x and y are overwritten.
It becomes x=10, y=20.
It becomes x=10, y=20.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers