C++ Programming - Objects and Classes - Discussion

Discussion Forum : Objects and Classes - Programs (Q.No. 9)
9.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class BixData
{
    int x, y, z; 
    public:
    BixData(int xx, int yy, int zz)
    {
        x = ++xx;
        y = ++yy;
        z = ++zz;
    }
    void Show()
    {
        cout<< "" << x++ << " " << y++ << " " << z++;
    } 
}; 
int main()
{
    BixData objData(1, 2, 3);
    objData.Show();
    return 0; 
}
The program will print the output 1 2 3.
The program will print the output 2 3 4 .
The program will print the output 4 5 6.
The program will report compile time error.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
2 comments Page 1 of 1.

Dinu said:   1 decade ago
The correct program is this.........!
#include<iostream.h>

class BixData
{
int x, y, z;
public:
BixData(int xx, int yy, int zz)
{
x = ++xx;
y = ++yy;
z = ++zz;
}
void Show()
{
cout<< "" << x++ << " " << y++ << " " << z++;
}
};
int main()
{
BixData objData(1, 2, 3);
objData.Show();
return 0;
}

Satheesh said:   1 decade ago
Using constructor xx, yy, zz values are incremented and using show function they are displayed.

Post your comments here:

Your comments will be displayed after verification.