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;
}
Discussion:
2 comments Page 1 of 1.
Satheesh said:
1 decade ago
Using constructor xx, yy, zz values are incremented and using show function they are displayed.
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;
}
#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;
}
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers