104. Destructors-II

Question.7

A derived class adds a buffer to a base class:

class Base {
public:
   Base() { printf("B+"); }
   ~Base() { printf("B-"); }
};

class Derived : public Base {
   uint8_t* buf;
public:
   Derived() : buf(new uint8_t[32]) { printf("D+"); }
   ~Derived() { delete[] buf; printf("D-"); }
};

{ Derived d; }

What is the output?

Need Help? Refer to the Quick Guide below

Select Answer