C++ Programming - Constructors and Destructors - Discussion
Discussion Forum : Constructors and Destructors - Programs (Q.No. 19)
19.
What will be the out of the following program?
#include<iostream.h>
class BixBase
{
public:
int x, y;
public:
BixBase(int xx = 0, int yy = 0)
{
x = xx;
y = yy;
}
};
class BixDerived : public BixBase
{
private:
BixBase objBase;
public:
BixDerived(int xx, int yy) : BixBase(xx), objBase(yy)
{
cout << this->x << " "
<< this->y << " "
<< objBase.x << " "
<< objBase.y << " ";
}
~BixDerived()
{ }
};
int main()
{
BixDerived objDev(11, 22);
return 0;
}
Discussion:
4 comments Page 1 of 1.
Rt45 said:
1 decade ago
Here xx=11 and yy=22.
The constructor for BixBase is called with argument xx=11, n default argument yy=0;
The constructor for objbase is called with argument xx=22, n default argument yy=0;
The constructor for BixBase is called with argument xx=11, n default argument yy=0;
The constructor for objbase is called with argument xx=22, n default argument yy=0;
Ravi said:
1 decade ago
Not clear please explain above program with simple example. Thanks in advance.
Neha said:
7 years ago
Thanks for explaining it @Rt45.
Shanu said:
1 decade ago
Please explain it.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers