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 3 of 3.

Sujeeth said:   1 decade ago
No I am not agree with it @Ashwak.

Class member's default values is not zero. Static storage duration are zero-initialized at the program startup.

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

Dhruv said:   1 decade ago
Why its not garbage ?

Sonal said:   1 decade ago
How can default value be '0' in this case ?

Pooja said:   1 decade ago
Is it displaying the default value of y i.e.=0;


Post your comments here:

Your comments will be displayed after verification.