C++ Programming - Constructors and Destructors - Discussion
Discussion Forum : Constructors and Destructors - Programs (Q.No. 20)
20.
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 << x << " "
<< this->x << " "
<< BixBase::x << " "
<< this->objBase.x ;
}
~BixDerived()
{ }
};
int main()
{
BixDerived objDev(11, 22);
return 0;
}
Discussion:
4 comments Page 1 of 1.
Pkc said:
9 years ago
First value is passed to base class.
Derived class access the values.
Like bixbase(x,y) = bixbase(11,0).
Objbase(x,y) = Objbase(22,0).
Derived class access the values.
Like bixbase(x,y) = bixbase(11,0).
Objbase(x,y) = Objbase(22,0).
Mdk said:
7 years ago
How it display 22? Please explain.
Mrdeath001 said:
6 years ago
Explain the second last 22.
IYAPPAN said:
10 years ago
Please explain it.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers