What is the output of the program?
#include
using namespace std;
class bclass
{
public:
a. void print() const;
bclass(int a = 0, int b = 0);
//postcondition: x = a; y = b;
private:
int x;
int y;
};
class dclass: public bclass
{
public:
b. void print() const;
dclass(int a = 0, int b = 0, int c = 0);
//postcondition: x = a; y = b; z = c;
private:
int z;
};
int main()
{
bclass bobject(2, 3);
dclass dobject(3, 5, 8);
bobject. print();
cout < < endl;
dobject. print();
cout < < endl;
return 0 ;
}
c. void bclass: : print() const
{
cout < < x < < " " < < y < < endl;
}
bclass: : bclass(int a, int b)
{
x = a;
y = b;
}
d. void dclass: : print() const
{
bclass: : print(); //added second colon
cout < < " " < < z < < endl;
}
dclass: : dclass(int a, int b, int c)
: bclass(a, b)
{
z = c;
}