C++ Programming - References - Discussion
Discussion Forum : References - Programs (Q.No. 16)
16.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class Bix
{
int x, y;
public:
Bix(int x, int y)
{
this->x = x;
this->y = y;
}
void Display()
{
cout<< x << " " << y;
}
};
int main()
{
int x = 50;
int &y = x ;
Bix b(y, x);
return 0;
}
Discussion:
5 comments Page 1 of 1.
Vishal Singh said:
7 years ago
@Adi.
Even if we add a b.Display() call in the program it does not throw any error, so the declaration is correct and it returns values as 50 50.
Even if we add a b.Display() call in the program it does not throw any error, so the declaration is correct and it returns values as 50 50.
Shambhu said:
8 years ago
std::cout << x << y << endl; must be used or std namespace must be added.
Adi said:
1 decade ago
In the function definition, shouldn't it be Bix (int &x, int y) instead of Bix (int x, int y) ?
So compiler error should be there. Please clarify.
So compiler error should be there. Please clarify.
Rajesh reddy said:
1 decade ago
Don't print anything because externally we don't call any display function.
PRIYANK said:
1 decade ago
The program will print nothing because we are not calling "Display()".
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers