C++ Programming - References - Discussion
Discussion Forum : References - Programs (Q.No. 13)
13.
Which of the following statement is correct about the program given below?
#include<iostream.h>
struct Bix
{
short n;
};
int main()
{
Bix b;
Bix& rb = b;
b.n = 5;
cout << b.n << " " << rb.n << " ";
rb.n = 8;
cout << b.n << " " << rb.n;
return 0;
}
Discussion:
4 comments Page 1 of 1.
Julien said:
6 years ago
You can use "Bix b;", it is correct in C++ (not in C).
But yes it will not compile as well as other questions(It's strange that nobody point that). They don't use any namespace, so cout is unknwon.
But yes it will not compile as well as other questions(It's strange that nobody point that). They don't use any namespace, so cout is unknwon.
Rishabh said:
7 years ago
It will result in compile-time error because Bix b is not correct. It has to be struct Bix b;.
Anonymous said:
8 years ago
Here b=&rb.
In the question, its mentioned that b=5 therefore, rb=5.
Then rb is initialized to 8 so b = 8.
rb value will be assigned to b.
So, it is 5 5 8 8.
In the question, its mentioned that b=5 therefore, rb=5.
Then rb is initialized to 8 so b = 8.
rb value will be assigned to b.
So, it is 5 5 8 8.
Ronit said:
10 years ago
Explain it.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers