C++ Programming - Objects and Classes - Discussion

Discussion Forum : Objects and Classes - Programs (Q.No. 17)
17.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class BixBase
{
    int x, y; 
    public:
    BixBase(int xx = 10, int yy = 10)
    {
        x = xx;
        y = yy;
    }
    void Show()
    {
        cout<< x * y << endl;
    }
};
class BixDerived : public BixBase
{
    private:
        BixBase objBase; 
    public:
    BixDerived(int xx, int yy) : BixBase(xx, yy), objBase(yy, yy)
    {
        objBase.Show();
    }
};
int main()
{
    BixDerived objDev(10, 20);
    return 0; 
}
The program will print the output 100.
The program will print the output 200.
The program will print the output 400.
The program will print the output Garbage-value.
The program will report compile time error.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
5 comments Page 1 of 1.

Andreas said:   5 years ago
This program will fail to compile.
The include statement should read #include<iostream>, instead of #include<iostream.h>
Also, "cout" and "cendl" need to be prefixed with "std::"

Sangita said:   10 years ago
What is the requirement of writing BixBase (xx, yy) in below line?

BixDerived (int xx, int yy) : BixBase (xx, yy), objBase (yy, yy);

Without BixBase (xx, yy) also, the output is coming same.

Sreenath. said:   1 decade ago
The parameters passed through objBase(yy, yy) are 20 and 20, So the show() method returns 20*20=400.

Dnayneshwar said:   1 decade ago
Is there any priority for member initialization list ?

Right to Left or something like that ?

Kiuite said:   2 years ago
objBase(yy,yy) = objBase(20,20) = 20*20= 400'

Post your comments here:

Your comments will be displayed after verification.