C++ Programming - Constructors and Destructors - Discussion
Discussion Forum : Constructors and Destructors - Programs (Q.No. 9)
9.
What will be the output of the following program?
#include<iostream.h>
class IndiaBix
{
int x, y;
public:
IndiaBix(int xx)
{
x = ++xx;
}
~IndiaBix()
{
cout<< x - 1 << " ";
}
void Display()
{
cout<< --x + 1 << " ";
}
};
int main()
{
IndiaBix objBix(5);
objBix.Display();
int *p = (int*) &objBix;
*p = 40;
objBix.Display();
return 0;
}
Discussion:
17 comments Page 2 of 2.
Bittoo said:
1 decade ago
When *p=40, how could x value modifies to 40? can anybody explain this?
Rajireddy-ou said:
1 decade ago
x is part of the obj. ptr is pointing to that obj. Internally *p = x.
Avc said:
7 years ago
I am not understanding this, Please anyone help me.
Suchismita said:
3 years ago
I don't understand. Please explain me.
Ghulam Mustafa said:
9 years ago
Anyone can Explain more precise?
Shanu said:
1 decade ago
Can anybody explain it.
Nadreen said:
1 decade ago
Please explain.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers