Have a question?
Message sent Close

CIS170C Programming Constructor That Assigns Default Values DeVry University

0
0 reviews
  • Description
  • Full Document
Blur-Preview

DeVry University

CIS170C Programming Constructor That Assigns Default Values DeVry University

(1) Code
RetailItem.h
#pragma once
#include <string>
using namespace std;
class RetailItem {
private://member access specifier
string description;
int unitsOnHand;
double price;
public://member access specifier
//Constructor that assigns default values
RetailItem();
//Constructor that accept arguments for each member variable
RetailItem(string, int, double);
void setDescription(string d);
void setUnitsOnHand(int u);
void setPrice(double p);
string getDescription() ;
int getUnitsOnHand() ;
double getPrice() ;
};
RetailItem.cpp
#include “RetailItem.h”
//Constructor that assigns default values
RetailItem::RetailItem()
{
this->description = “”;
this->unitsOnHand = 0;
this->price = 0.0;
}
//Constructor that accept arguments for each member variable
RetailItem::RetailItem(string d, int u, double p) {
this->description = d;
this->unitsOnHand = u;
this->price = p;

Preview

CIS170C Programming Constructor That Assigns Default Values DeVry University

NOTE: Please check the details before purchasing the document.

error: