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;
}
11 22 0 0
11 11 0 22
11 11 11 0
11 11 11 22
The program will report compile time error.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

Mrdeath001 said:   6 years ago
Explain the second last 22.

Mdk said:   7 years ago
How it display 22? Please explain.

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).

IYAPPAN said:   10 years ago
Please explain it.

Post your comments here:

Your comments will be displayed after verification.