Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this C++ error that I keep getting in my lab. Here is my code: #include stdafx.h #include #include #include #include RetailItem.h

I need help with this C++ error that I keep getting in my lab.

Here is my code:

#include "stdafx.h"

#include

#include

#include

#include "RetailItem.h"

using namespace std;

int main()

{

RetailItem Items[3];

// Welcome Message

cout << "Welcome to the Retail store!" << endl;

// Build new Item for first one

string newItem;

double newPrice;

int newQTY;

// make total on invetory

double totalINV;

// check if the price is greater then 0

do

{

cout << "Price must be greater than 0." << endl;

cout << "Please enter the price for item 1: $";

cin >> newPrice;

} while (newPrice < 1);

// check if the invetory is greater then 0

do

{

cout << "Inventory must be greater than 0." << endl;

cout << "Please enter the units on hand for item 1: ";

cin >> newQTY;

} while (newQTY < 1);

// create new item

cout << "Please enter the description for item 1: ";

cin >> newItem;

// Build Items

Items[0].SetDescribtion(newItem);

Items[0].SetPrice(newPrice);

Items[0].SetUnits(newQTY);

Items[1].SetDescribtion("Jeans");

Items[1].SetPrice(34.95);

Items[1].SetUnits(40);

Items[2].SetDescribtion("Long sleve shirt");

Items[2].SetPrice(24.95);

Items[2].SetUnits(20);

cout << " Display all items " << endl;

for (int i = 0; i <= 2; i++)

{

cout << "Describtion: " << Items[i].getDescription() << endl;

cout << "Unit on Hand: " << Items[i].getUnits() << endl;

cout << "Price: $" << Items[i].getPrice() << endl;

cout << " ";

}

totalINV = Items[0].getUnits() + Items[1].getUnits() + Items[2].getUnits();

cout << "Display the total inventory" << endl;

cout << "The total invetory is " << totalINV << endl;

system("pause");

}

//RetailItem.h

#ifndef __RETAILITEM_HPP__

#define __RETAILITEM_HPP__

#endif

#include

class RetailItem

{

private:

std::string description;

double price;

int unitOnHand;

public:

RetailItem()

{

description = "";

price = 0;

unitOnHand = 0;

}

RetailItem(std::string desc, double cost, int qty)

{

description = desc;

price = cost;

unitOnHand = qty;

}

std::string getDescription() { return description; }

double getPrice() { return price; }

int getUnits() { return unitOnHand; }

void SetDescribtion(std::string desc) { description = desc; }

void SetPrice(double cost) { price = cost; }

void SetUnits(int qty) { unitOnHand = qty; }

};

and here are the errors I've been getting:

Severity Code Description Project File Line Suppression State

Error C2065 'RetailItem': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 14

Error C2146 syntax error: missing ';' before identifier 'Items' LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 14

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 14

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 50

Error C2228 left of '.SetDescribtion' must have class/struct/union LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 50

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 51

Error C2228 left of '.SetPrice' must have class/struct/union LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 51

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 52

Error C2228 left of '.SetUnits' must have class/struct/union LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 52

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 54

Error C2228 left of '.SetDescribtion' must have class/struct/union LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 54

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 55

Error C2228 left of '.SetPrice' must have class/struct/union LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 55

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 56

Error C2228 left of '.SetUnits' must have class/struct/union LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 56

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 58

Error C2228 left of '.SetDescribtion' must have class/struct/union LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 58

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 59

Error C2228 left of '.SetPrice' must have class/struct/union LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 59

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 60

Error C2228 left of '.SetUnits' must have class/struct/union LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 60

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 65

Error C2228 left of '.getDescription' must have class/struct/union LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 65

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 66

Error C2228 left of '.getUnits' must have class/struct/union LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 66

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 67

Error C2228 left of '.getPrice' must have class/struct/union LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 67

Error C2065 'Items': undeclared identifier LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 71

Error C2228 left of '.getUnits' must have class/struct/union LAB6 c:\users\kevin\source epos\lab6\lab6\lab6.cpp 71

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

9.4 Tests of the Population Proportion (Large Samples)

Answered: 1 week ago