C++ Programming - Objects and Classes - Discussion
Discussion Forum : Objects and Classes - Programs (Q.No. 4)
4.
What will be the output of the following program?
#include<iostream.h>
class BixTeam
{
int x, y;
public:
BixTeam(int xx)
{
x = ++xx;
}
void Display()
{
cout<< --x << " ";
}
};
int main()
{
BixTeam objBT(45);
objBT.Display();
int *p = (int*)&objBT;
*p = 23;
objBT.Display();
return 0;
}
Discussion:
13 comments Page 2 of 2.
Swati said:
1 decade ago
What about 23?
Bharat said:
1 decade ago
Bro 45 is incremented by 1 in constructor definition, it becomes 46. And also we decrements by 1 when we display the value of x, that time it becomes 45.
Anonymous said:
1 decade ago
Why 45 is not incremented?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers