User Report

#include "InventoryItem.h" // Private member function. void InventoryItem::createDescription(int size, char *value) { // Allocate the default amount of memory for description. description = new char [size]; // Store a value in the memory. strcpy(description, value); } // Constructor #1 InventoryItem::InventoryItem() { // Store an empty string in the description // attribute. createDescription(DEFAULT_SIZE, ""); // Initialize cost and units. cost = 0.0; units = 0; } // Constructor #2 InventoryItem::InventoryItem(char *desc) { // Allocate memory and store the description. createDescription(strlen(desc), desc); // Initialize cost and units. cost = 0.0; units = 0; } // Constructor #3 InventoryItem::InventoryItem(char *desc, double c, int u) { // Allocate memory and store the description. createDescription(strlen(desc), desc); // Assign values to cost and units. cost = c; units = u; } // Destructor InventoryItem::~InventoryItem() { delete [] description; } // Mutator functions void InventoryItem::setDescription(char *d) { strcpy(description, d); } void InventoryItem::setCost(double c) { cost = c; } void InventoryItem::setUnits(int u) { units = u; } // Accessor functions const char *InventoryItem::getDescription() const { return description; } double InventoryItem::getCost() const { return cost; } int InventoryItem::getUnits() const { return units; }

Submit Your Homework

Let us help you with your homework, we will match you with one of our professional tutors.

My Info

Project Info

Due Date

Describe your Homework Problem

Budget (optional)

By providing your budget we will work on finding the best tutors that can work within it.

Get help from top-rated tutors in any subject.

Efficiently complete your homework and academic assignments by getting help from the experts at homeworkarchive.com