Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have to make a new class called retailer class. It\'s inherits methods from bo

ID: 3556213 • Letter: I

Question

I have to make a new class called retailer class. It's inherits methods from both a buyer and seller class and needs to use both methods. However, buyer and seller are both derived from the same base class, called entity

let's take a method that I worked out called step:

this is buyer's version of step:

void Buyer::step()
{

code..

}

and this is seller's version:

void Seller::step()
{
different code...
}

I need my retailer to do BOTH Methods for it's step() function. I have no idea how to go about this. Do I need to write a new body for retailer that does both methods? that seems pointless, why would it be inherited then? any help is appreciated. I've read a bit about the "virtual", but I'm very lost.

do i do this when I make my class definition (h file)?

class Retailer : public virtual Buyer, public virtual Seller

then write a new method for retailer? like i did when i extended buyer and seller from entity?

Explanation / Answer

You can call them for retailer without writing the functions again.

like this:

Buyer obj1= new Retailer();

obj1.srep(); //for step function in Buyer class

and

Seller obj2= new Retailer();

obj2.srep(); //for step function in Seller class