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
Get step-by-step solutions from verified subject matter experts
