Question: What is wrong with the following code? class B { public: B(); B(int n); void print() const; private: int b; }; B::B() { b =

What is wrong with the following code?

class B {

public:

B();

B(int n); void print() const;

private:

int b;

}; B::B()

{

b = 0;

} B::B(int n)

{

b = n;

} void B::print() const

{

cout << "B: " << b << " ";

} class D : public B

{

public:

D();

D(int n);

void print() const;

}; D::D() {

}

D::D(int n) {

b = n;

}

void D::print() const

{

cout << "D: " << b << " ";

}

How can you x the errors?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!