C++ Programming - Objects and Classes - Discussion
Discussion Forum : Objects and Classes - Programs (Q.No. 6)
6.
What will be the output of the following program?
#include<iostream.h>
class India
{
public:
struct Bix
{
int x;
float y;
void Function(void)
{
y = x = (x = 4*4);
y = --y * y;
}
void Display()
{
cout<< y << endl;
}
}B;
}I;
int main()
{
I.B.Display();
return 0;
}
Discussion:
25 comments Page 3 of 3.
Faree said:
9 years ago
Functions can't be defined inside a structure, so how the answer is 0?
Swetha said:
8 years ago
Hello.
I'd like to assert that the main function is returning a 0,
hence, 0!.
I'd like to assert that the main function is returning a 0,
hence, 0!.
Tanmay said:
8 years ago
The void Function (void) will not be called simply.
If we have written I.B.Function then things would have been different.
If we have written I.B.Function then things would have been different.
Neha said:
7 years ago
Because y is global variable for function display and global variable value by default is zero.
(1)
Paanku said:
7 years ago
It is because we have a global object.
For global objects, all members are initialised to zero.
For global objects, all members are initialised to zero.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers