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;
}
0
1
-1
Garbage value
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
25 comments Page 2 of 3.

Nuzhat said:   10 years ago
y = x = (x = 4*4).

Explain above in details.

x = 4*4 = 16?

How could it 1?

Mukesh said:   1 decade ago
Yes, Structure members are initialized to zero if not defined explicitly.

Ashwak said:   1 decade ago
For class members and structure members the default value will be zero.

Faree said:   9 years ago
Functions can't be defined inside a structure, so how the answer is 0?

Shantayya said:   1 decade ago
Structure members are initialized to zero if not defined explicitly.

Nikhil said:   9 years ago
How the output will be zero?

Not understand please explain it.

Sonali said:   1 decade ago
Where it is declared global? please explain program in detail.

Rajit said:   1 decade ago
Object Declared as global.

So all global default value = 0.

Jeet said:   1 decade ago
Yes, but this is not structure please explain in detail.

Priya said:   1 decade ago
Why answer is zero? How the function is evaluated?


Post your comments here:

Your comments will be displayed after verification.