SlideShare a Scribd company logo
Why won't my code build and run? and what is the correct code so it builds successfully?
getting errors in the Product.cpp file error:(Expected unqualified-id)
all code below and files
Main.cpp
#include <iostream>
#include <time.h>
#include "InventorySystem.hpp"
#include <iostream>
#include "Product.hpp"
#include <time.h>
#include <stdlib.h>
using namespace std;
int main() {
srand(time( NULL ));
Inventory_System *h1 = nullptr ;
h1 = new Inventory_System("Radioshack", 117);
h1->BuildInventory();
h1->ShowInventory();
h1->ShowDefectInventory();
h1->Terminate();
delete h1;
return 0;
};
InventorySystem.cpp
#include "InventorySystem.hpp"
#include "InventoryItem.hpp"
#include "Product.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
Inventory_System::Inventory_System() {
}
Inventory_System::Inventory_System(std::string name, int id) :
store_name(name),
store_id(id) {
}
Inventory_System::~Inventory_System() {
for ( int i = 0; i < item_count; i++) {
delete ptr_inv_item[i];
}
}
int Inventory_System::GetStoreId(){
return store_id;
}
int Inventory_System::GetItemCount(){
return item_count;
}
std::string Inventory_System::GetStoreName(){
return store_name;
}
void Inventory_System::BuildInventory() {
std::ifstream file("products_test.txt", std::ios::in);
std::string name, quantity, price, condition;
Inventory_Item *item;
if (!file) {
std::cerr << "Error: Failed to open filen";
exit(-1);
}
else {
while (!file.eof()) {
item = new Product();
Product *product = static_cast <Product*> (item);
std::getline(file, name, ';');
product->SetItemName(name);
std::getline(file, quantity, ';');
product->SetItemQuantity(stoi(quantity));
std::getline(file, price, ';');
product->SetProductPrice(stold(price));
std::getline(file, condition, 'n');
switch (condition[0]) {
case 'D':
product->SetProductCondition(PC_DEFECTIVE);
break ;
case 'N':
product->SetProductCondition(PC_NEW);
break ;
case 'R':
product->SetProductCondition(PC_REFURBISHED);
break ;
case 'U':
product->SetProductCondition(PC_USED);
break ;
default :
product->SetProductCondition(PC_NEW);
break ;
}
product->SetProductId(rand() % 10000);
ptr_inv_item[item_count] = product;
item_count++;
}
}
}
void Inventory_System::ShowInventory() {
for ( int i = 0; i < item_count; i++) {
Product *temp = static_cast <Product*> (ptr_inv_item[i]);
temp->Display();
}
}
void Inventory_System::ShowDefectInventory() {
for ( int i = 0; i < item_count; i++) {
Product *temp = static_cast <Product*> (ptr_inv_item[i]);
if (temp->GetProductCondition() == PC_DEFECTIVE) {
temp->Display();
}
}
}
void Inventory_System::Terminate() {
std::ofstream file;
std::stringstream ss;
file.open("example.txt");
for ( int i = 0; i < item_count; i++) {
Product *temp = static_cast <Product*> (ptr_inv_item[i]);
file << temp->GetItemName() << ";"
<< temp->GetItemQuantity() << ";"
<< temp->GetProductPrice() << ";";
switch (temp->GetProductCondition()) {
case PC_DEFECTIVE:
file << "Dn";
break ;
case PC_NEW:
file << "Nn";
break ;
case PC_REFURBISHED:
file << "Rn";
break ;
case PC_USED:
file << "Un";
break ;
default :
file << "Dn";
break ;
}
}
}
InventorySystem.h
#ifndef InventorySystem_hpp
#define InventorySystem_hpp
#include "InventoryItem.hpp"
#include "Product.hpp"
#include <stdio.h>
#include <string>
class Inventory_System {
public :
Inventory_System();
Inventory_System(std::string, int );
~Inventory_System();
int GetStoreId();
int GetItemCount();
std::string GetStoreName();
void BuildInventory();
void ShowInventory();
void ShowDefectInventory();
void Terminate();
private :
std::string store_name;
int store_id, item_count = 0;
Inventory_Item **ptr_inv_item = new Inventory_Item*[512];
};
#endif /* InventorySystem_hpp */
InventoryItem.cpp
#include "InventoryItem.hpp"
#include <iostream>
Inventory_Item::Inventory_Item(){
}
Inventory_Item::Inventory_Item(std::string name, int quantity) :
item_name(name),
item_quantity(quantity) {
}
Inventory_Item::~Inventory_Item() {
std::cout << "Inventory Item " << item_name << " with " << item_quantity << " item(s)
destroyed.n";
}
std::string Inventory_Item::GetItemName() const {
return item_name;
}
int Inventory_Item::GetItemQuantity() const {
return item_quantity;
}
void Inventory_Item::SetItemName(std::string name) {
item_name = name;
}
void Inventory_Item::SetItemQuantity( int quantity) {
item_quantity = quantity;
}
void Inventory_Item::Display() const {
std::cout << item_name << " (" << item_quantity << ") ";
}
InventoryItem.h
#ifndef InventoryItem_hpp
#define InventoryItem_hpp
#include <stdio.h>
#include <string>
class Inventory_Item {
public :
Inventory_Item();
Inventory_Item(std::string name, int quantity);
~Inventory_Item();
std::string GetItemName() const ;
int GetItemQuantity() const ;
void SetItemName(std::string);
void SetItemQuantity( int );
virtual void Display() const ;
protected :
std::string item_name;
int item_quantity;
private :
};
#endif /* InventoryItem_hpp */
Product.cpp
#include "Product.hpp"
#include <iostream>
#include <iomanip>
Product::Product() :
Inventory_Item(),
product_id(0),
product_price(0.0) {
}
Inventory_Item(),
product_id(0),
product_price(0.0){
}
Product::Product(std::string name, int quantity) :
Inventory_Item(name, quantity),
product_id(rand()% 1000),
product_price(100.0 * ((rand() + 1) / double (RAND_MAX + 2))){
}
Product::~Product() {
std::cout << "Product " << product_id << " priced $" << product_price << " has been
destroyed.";
}
int Product::GetProductId() const {
return product_id;
}
double Product::GetProductPrice() const {
return product_price;
}
T_Condition Product::GetProductCondition() const {
return condition_;
}
void Product::SetProductId( int id){
product_id = id;
}
void Product::SetProductPrice( double price) {
product_price = price;
}
void Product::SetProductCondition(T_Condition condition) {
condition_ = condition;
}
void Product::Display() const {
Inventory_Item::Display();
std::cout << product_id << " $" << std::setprecision(4) << product_price << 'n';
}
Product.h
#ifndef Product_hpp
#define Product_hpp
#include "InventoryItem.hpp"
#include <stdio.h>
#include "Product.hpp"
#include <string>
typedef enum { PC_NEW, PC_USED, PC_REFURBISHED, PC_DEFECTIVE } T_Condition;
class Product : public Inventory_Item {
public :
Product();
Product(std::string, int );
~Product();
int GetProductId() const ;
double GetProductPrice() const ;
T_Condition GetProductCondition() const ;
void SetProductId( int );
void SetProductPrice( double );
void SetProductCondition(T_Condition);
virtual void Display() const ;
private :
T_Condition condition_;
int product_id;
double product_price;
};
#endif /* Product_hpp */
Why won't my code build and run- and what is the correct code so it bu.pdf

More Related Content

Similar to Why won't my code build and run- and what is the correct code so it bu.pdf

Writing native bindings to node.js in C++
Writing native bindings to node.js in C++Writing native bindings to node.js in C++
Writing native bindings to node.js in C++nsm.nikhil
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Juan Pablo
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js ModuleFred Chien
 
Threads and Callbacks for Embedded Python
Threads and Callbacks for Embedded PythonThreads and Callbacks for Embedded Python
Threads and Callbacks for Embedded PythonYi-Lung Tsai
 
CPP Programming Homework Help
CPP Programming Homework HelpCPP Programming Homework Help
CPP Programming Homework HelpC++ Homework Help
 
#include stdio.h#include stdlib.h#include string.hstruct.pdf
#include stdio.h#include stdlib.h#include string.hstruct.pdf#include stdio.h#include stdlib.h#include string.hstruct.pdf
#include stdio.h#include stdlib.h#include string.hstruct.pdfanubhavnigam2608
 
Introduction to Spring Boot.pdf
Introduction to Spring Boot.pdfIntroduction to Spring Boot.pdf
Introduction to Spring Boot.pdfShaiAlmog1
 
maincpp include ListItemh include ltstringgt in.pdf
maincpp include ListItemh include ltstringgt in.pdfmaincpp include ListItemh include ltstringgt in.pdf
maincpp include ListItemh include ltstringgt in.pdfabiwarmaa
 
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfaassecuritysystem
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?Andrey Karpov
 
#include customer.h#include heap.h#include iostream.docx
#include customer.h#include heap.h#include iostream.docx#include customer.h#include heap.h#include iostream.docx
#include customer.h#include heap.h#include iostream.docxAASTHA76
 
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docxIn Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docxbradburgess22840
 
This is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfThis is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfinfo334223
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxssuser454af01
 

Similar to Why won't my code build and run- and what is the correct code so it bu.pdf (20)

Writing native bindings to node.js in C++
Writing native bindings to node.js in C++Writing native bindings to node.js in C++
Writing native bindings to node.js in C++
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
 
Threads and Callbacks for Embedded Python
Threads and Callbacks for Embedded PythonThreads and Callbacks for Embedded Python
Threads and Callbacks for Embedded Python
 
Android ndk
Android ndkAndroid ndk
Android ndk
 
CPP Programming Homework Help
CPP Programming Homework HelpCPP Programming Homework Help
CPP Programming Homework Help
 
Lecture2.ppt
Lecture2.pptLecture2.ppt
Lecture2.ppt
 
OpenCMIS Part 1
OpenCMIS Part 1OpenCMIS Part 1
OpenCMIS Part 1
 
#include stdio.h#include stdlib.h#include string.hstruct.pdf
#include stdio.h#include stdlib.h#include string.hstruct.pdf#include stdio.h#include stdlib.h#include string.hstruct.pdf
#include stdio.h#include stdlib.h#include string.hstruct.pdf
 
Introduction to Spring Boot.pdf
Introduction to Spring Boot.pdfIntroduction to Spring Boot.pdf
Introduction to Spring Boot.pdf
 
maincpp include ListItemh include ltstringgt in.pdf
maincpp include ListItemh include ltstringgt in.pdfmaincpp include ListItemh include ltstringgt in.pdf
maincpp include ListItemh include ltstringgt in.pdf
 
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?
 
#include customer.h#include heap.h#include iostream.docx
#include customer.h#include heap.h#include iostream.docx#include customer.h#include heap.h#include iostream.docx
#include customer.h#include heap.h#include iostream.docx
 
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docxIn Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
 
This is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfThis is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdf
 
C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
 
V8
V8V8
V8
 

More from umeshagarwal39

Write a c++ program that will input TWO characters then print if it is.pdf
Write a c++ program that will input TWO characters then print if it is.pdfWrite a c++ program that will input TWO characters then print if it is.pdf
Write a c++ program that will input TWO characters then print if it is.pdfumeshagarwal39
 
Wredk 10-5 Ps- Rob- Fes- me ton- Would youi like to haye a cotfer Thre.pdf
Wredk 10-5 Ps- Rob- Fes- me ton- Would youi like to haye a cotfer Thre.pdfWredk 10-5 Ps- Rob- Fes- me ton- Would youi like to haye a cotfer Thre.pdf
Wredk 10-5 Ps- Rob- Fes- me ton- Would youi like to haye a cotfer Thre.pdfumeshagarwal39
 
Write 200-250 words Q-1 Identify specific examples of different stake.pdf
Write 200-250 words  Q-1 Identify specific examples of different stake.pdfWrite 200-250 words  Q-1 Identify specific examples of different stake.pdf
Write 200-250 words Q-1 Identify specific examples of different stake.pdfumeshagarwal39
 
Working with the Concepts 5- Cable subscriptions decline- The number o.pdf
Working with the Concepts 5- Cable subscriptions decline- The number o.pdfWorking with the Concepts 5- Cable subscriptions decline- The number o.pdf
Working with the Concepts 5- Cable subscriptions decline- The number o.pdfumeshagarwal39
 
Within the organizational structure of Philips- the national organizat.pdf
Within the organizational structure of Philips- the national organizat.pdfWithin the organizational structure of Philips- the national organizat.pdf
Within the organizational structure of Philips- the national organizat.pdfumeshagarwal39
 
With appropriate referencing and elaborate explanation- write a minimu.pdf
With appropriate referencing and elaborate explanation- write a minimu.pdfWith appropriate referencing and elaborate explanation- write a minimu.pdf
With appropriate referencing and elaborate explanation- write a minimu.pdfumeshagarwal39
 
Winger corporation was organized in March- It is authorized to issue 5.pdf
Winger corporation was organized in March- It is authorized to issue 5.pdfWinger corporation was organized in March- It is authorized to issue 5.pdf
Winger corporation was organized in March- It is authorized to issue 5.pdfumeshagarwal39
 
William Ouchi's Theory Z recognized Multiple Choice the combined benef.pdf
William Ouchi's Theory Z recognized Multiple Choice the combined benef.pdfWilliam Ouchi's Theory Z recognized Multiple Choice the combined benef.pdf
William Ouchi's Theory Z recognized Multiple Choice the combined benef.pdfumeshagarwal39
 
Wildhorse Company has a balancet in its Accouats Receivable control ac.pdf
Wildhorse Company has a balancet in its Accouats Receivable control ac.pdfWildhorse Company has a balancet in its Accouats Receivable control ac.pdf
Wildhorse Company has a balancet in its Accouats Receivable control ac.pdfumeshagarwal39
 
Wildhorse Company has a balance in its Accounts Recevvable control acc.pdf
Wildhorse Company has a balance in its Accounts Recevvable control acc.pdfWildhorse Company has a balance in its Accounts Recevvable control acc.pdf
Wildhorse Company has a balance in its Accounts Recevvable control acc.pdfumeshagarwal39
 
why does this code keep generating this error- even though the URL is.pdf
why does this code keep generating this error- even though the URL is.pdfwhy does this code keep generating this error- even though the URL is.pdf
why does this code keep generating this error- even though the URL is.pdfumeshagarwal39
 
Why do you think the SEC (should or should not) to go after celebritie.pdf
Why do you think the SEC (should or should not) to go after celebritie.pdfWhy do you think the SEC (should or should not) to go after celebritie.pdf
Why do you think the SEC (should or should not) to go after celebritie.pdfumeshagarwal39
 
Who would be at increased risk for vitamin B12 deficiency without fort.pdf
Who would be at increased risk for vitamin B12 deficiency without fort.pdfWho would be at increased risk for vitamin B12 deficiency without fort.pdf
Who would be at increased risk for vitamin B12 deficiency without fort.pdfumeshagarwal39
 
Why are funny channels -funny- (different from other channels)- Becaus.pdf
Why are funny channels -funny- (different from other channels)- Becaus.pdfWhy are funny channels -funny- (different from other channels)- Becaus.pdf
Why are funny channels -funny- (different from other channels)- Becaus.pdfumeshagarwal39
 
Why do we try to remove air bubbles in the electroblot set up- Protein.pdf
Why do we try to remove air bubbles in the electroblot set up- Protein.pdfWhy do we try to remove air bubbles in the electroblot set up- Protein.pdf
Why do we try to remove air bubbles in the electroblot set up- Protein.pdfumeshagarwal39
 
Why do we need Confusion matrix-What is recall- accuracy- precision an.pdf
Why do we need Confusion matrix-What is recall- accuracy- precision an.pdfWhy do we need Confusion matrix-What is recall- accuracy- precision an.pdf
Why do we need Confusion matrix-What is recall- accuracy- precision an.pdfumeshagarwal39
 
Which of these is the best example of mechanical digestion- Group of a.pdf
Which of these is the best example of mechanical digestion- Group of a.pdfWhich of these is the best example of mechanical digestion- Group of a.pdf
Which of these is the best example of mechanical digestion- Group of a.pdfumeshagarwal39
 
Whispering Winds Corp- reported these income statement data for a 2-ye.pdf
Whispering Winds Corp- reported these income statement data for a 2-ye.pdfWhispering Winds Corp- reported these income statement data for a 2-ye.pdf
Whispering Winds Corp- reported these income statement data for a 2-ye.pdfumeshagarwal39
 
While in her hepatocyte- you notice that a molecule of carbon dioxide.pdf
While in her hepatocyte- you notice that a molecule of carbon dioxide.pdfWhile in her hepatocyte- you notice that a molecule of carbon dioxide.pdf
While in her hepatocyte- you notice that a molecule of carbon dioxide.pdfumeshagarwal39
 
Which was not a reason it took 100 years for the Copernican Revolution.pdf
Which was not a reason it took 100 years for the Copernican Revolution.pdfWhich was not a reason it took 100 years for the Copernican Revolution.pdf
Which was not a reason it took 100 years for the Copernican Revolution.pdfumeshagarwal39
 

More from umeshagarwal39 (20)

Write a c++ program that will input TWO characters then print if it is.pdf
Write a c++ program that will input TWO characters then print if it is.pdfWrite a c++ program that will input TWO characters then print if it is.pdf
Write a c++ program that will input TWO characters then print if it is.pdf
 
Wredk 10-5 Ps- Rob- Fes- me ton- Would youi like to haye a cotfer Thre.pdf
Wredk 10-5 Ps- Rob- Fes- me ton- Would youi like to haye a cotfer Thre.pdfWredk 10-5 Ps- Rob- Fes- me ton- Would youi like to haye a cotfer Thre.pdf
Wredk 10-5 Ps- Rob- Fes- me ton- Would youi like to haye a cotfer Thre.pdf
 
Write 200-250 words Q-1 Identify specific examples of different stake.pdf
Write 200-250 words  Q-1 Identify specific examples of different stake.pdfWrite 200-250 words  Q-1 Identify specific examples of different stake.pdf
Write 200-250 words Q-1 Identify specific examples of different stake.pdf
 
Working with the Concepts 5- Cable subscriptions decline- The number o.pdf
Working with the Concepts 5- Cable subscriptions decline- The number o.pdfWorking with the Concepts 5- Cable subscriptions decline- The number o.pdf
Working with the Concepts 5- Cable subscriptions decline- The number o.pdf
 
Within the organizational structure of Philips- the national organizat.pdf
Within the organizational structure of Philips- the national organizat.pdfWithin the organizational structure of Philips- the national organizat.pdf
Within the organizational structure of Philips- the national organizat.pdf
 
With appropriate referencing and elaborate explanation- write a minimu.pdf
With appropriate referencing and elaborate explanation- write a minimu.pdfWith appropriate referencing and elaborate explanation- write a minimu.pdf
With appropriate referencing and elaborate explanation- write a minimu.pdf
 
Winger corporation was organized in March- It is authorized to issue 5.pdf
Winger corporation was organized in March- It is authorized to issue 5.pdfWinger corporation was organized in March- It is authorized to issue 5.pdf
Winger corporation was organized in March- It is authorized to issue 5.pdf
 
William Ouchi's Theory Z recognized Multiple Choice the combined benef.pdf
William Ouchi's Theory Z recognized Multiple Choice the combined benef.pdfWilliam Ouchi's Theory Z recognized Multiple Choice the combined benef.pdf
William Ouchi's Theory Z recognized Multiple Choice the combined benef.pdf
 
Wildhorse Company has a balancet in its Accouats Receivable control ac.pdf
Wildhorse Company has a balancet in its Accouats Receivable control ac.pdfWildhorse Company has a balancet in its Accouats Receivable control ac.pdf
Wildhorse Company has a balancet in its Accouats Receivable control ac.pdf
 
Wildhorse Company has a balance in its Accounts Recevvable control acc.pdf
Wildhorse Company has a balance in its Accounts Recevvable control acc.pdfWildhorse Company has a balance in its Accounts Recevvable control acc.pdf
Wildhorse Company has a balance in its Accounts Recevvable control acc.pdf
 
why does this code keep generating this error- even though the URL is.pdf
why does this code keep generating this error- even though the URL is.pdfwhy does this code keep generating this error- even though the URL is.pdf
why does this code keep generating this error- even though the URL is.pdf
 
Why do you think the SEC (should or should not) to go after celebritie.pdf
Why do you think the SEC (should or should not) to go after celebritie.pdfWhy do you think the SEC (should or should not) to go after celebritie.pdf
Why do you think the SEC (should or should not) to go after celebritie.pdf
 
Who would be at increased risk for vitamin B12 deficiency without fort.pdf
Who would be at increased risk for vitamin B12 deficiency without fort.pdfWho would be at increased risk for vitamin B12 deficiency without fort.pdf
Who would be at increased risk for vitamin B12 deficiency without fort.pdf
 
Why are funny channels -funny- (different from other channels)- Becaus.pdf
Why are funny channels -funny- (different from other channels)- Becaus.pdfWhy are funny channels -funny- (different from other channels)- Becaus.pdf
Why are funny channels -funny- (different from other channels)- Becaus.pdf
 
Why do we try to remove air bubbles in the electroblot set up- Protein.pdf
Why do we try to remove air bubbles in the electroblot set up- Protein.pdfWhy do we try to remove air bubbles in the electroblot set up- Protein.pdf
Why do we try to remove air bubbles in the electroblot set up- Protein.pdf
 
Why do we need Confusion matrix-What is recall- accuracy- precision an.pdf
Why do we need Confusion matrix-What is recall- accuracy- precision an.pdfWhy do we need Confusion matrix-What is recall- accuracy- precision an.pdf
Why do we need Confusion matrix-What is recall- accuracy- precision an.pdf
 
Which of these is the best example of mechanical digestion- Group of a.pdf
Which of these is the best example of mechanical digestion- Group of a.pdfWhich of these is the best example of mechanical digestion- Group of a.pdf
Which of these is the best example of mechanical digestion- Group of a.pdf
 
Whispering Winds Corp- reported these income statement data for a 2-ye.pdf
Whispering Winds Corp- reported these income statement data for a 2-ye.pdfWhispering Winds Corp- reported these income statement data for a 2-ye.pdf
Whispering Winds Corp- reported these income statement data for a 2-ye.pdf
 
While in her hepatocyte- you notice that a molecule of carbon dioxide.pdf
While in her hepatocyte- you notice that a molecule of carbon dioxide.pdfWhile in her hepatocyte- you notice that a molecule of carbon dioxide.pdf
While in her hepatocyte- you notice that a molecule of carbon dioxide.pdf
 
Which was not a reason it took 100 years for the Copernican Revolution.pdf
Which was not a reason it took 100 years for the Copernican Revolution.pdfWhich was not a reason it took 100 years for the Copernican Revolution.pdf
Which was not a reason it took 100 years for the Copernican Revolution.pdf
 

Recently uploaded

Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptSourabh Kumar
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxCapitolTechU
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfbu07226
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxbennyroshan06
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasiemaillard
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxJenilouCasareno
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chipsGeoBlogs
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfPo-Chuan Chen
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasiemaillard
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleCeline George
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfTamralipta Mahavidyalaya
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxricssacare
 
Advances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfAdvances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfDr. M. Kumaresan Hort.
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...Nguyen Thanh Tu Collection
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online PresentationGDSCYCCE
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 

Recently uploaded (20)

Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Advances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfAdvances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdf
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 

Why won't my code build and run- and what is the correct code so it bu.pdf

  • 1. Why won't my code build and run? and what is the correct code so it builds successfully? getting errors in the Product.cpp file error:(Expected unqualified-id) all code below and files Main.cpp #include <iostream> #include <time.h> #include "InventorySystem.hpp" #include <iostream> #include "Product.hpp" #include <time.h> #include <stdlib.h> using namespace std; int main() { srand(time( NULL )); Inventory_System *h1 = nullptr ; h1 = new Inventory_System("Radioshack", 117); h1->BuildInventory(); h1->ShowInventory(); h1->ShowDefectInventory(); h1->Terminate(); delete h1; return 0; };
  • 2. InventorySystem.cpp #include "InventorySystem.hpp" #include "InventoryItem.hpp" #include "Product.hpp" #include <iostream> #include <fstream> #include <sstream> Inventory_System::Inventory_System() { } Inventory_System::Inventory_System(std::string name, int id) : store_name(name), store_id(id) { } Inventory_System::~Inventory_System() { for ( int i = 0; i < item_count; i++) { delete ptr_inv_item[i]; } } int Inventory_System::GetStoreId(){ return store_id; } int Inventory_System::GetItemCount(){ return item_count;
  • 3. } std::string Inventory_System::GetStoreName(){ return store_name; } void Inventory_System::BuildInventory() { std::ifstream file("products_test.txt", std::ios::in); std::string name, quantity, price, condition; Inventory_Item *item; if (!file) { std::cerr << "Error: Failed to open filen"; exit(-1); } else { while (!file.eof()) { item = new Product(); Product *product = static_cast <Product*> (item); std::getline(file, name, ';'); product->SetItemName(name); std::getline(file, quantity, ';'); product->SetItemQuantity(stoi(quantity)); std::getline(file, price, ';'); product->SetProductPrice(stold(price)); std::getline(file, condition, 'n');
  • 4. switch (condition[0]) { case 'D': product->SetProductCondition(PC_DEFECTIVE); break ; case 'N': product->SetProductCondition(PC_NEW); break ; case 'R': product->SetProductCondition(PC_REFURBISHED); break ; case 'U': product->SetProductCondition(PC_USED); break ; default : product->SetProductCondition(PC_NEW); break ; } product->SetProductId(rand() % 10000); ptr_inv_item[item_count] = product; item_count++; } } }
  • 5. void Inventory_System::ShowInventory() { for ( int i = 0; i < item_count; i++) { Product *temp = static_cast <Product*> (ptr_inv_item[i]); temp->Display(); } } void Inventory_System::ShowDefectInventory() { for ( int i = 0; i < item_count; i++) { Product *temp = static_cast <Product*> (ptr_inv_item[i]); if (temp->GetProductCondition() == PC_DEFECTIVE) { temp->Display(); } } } void Inventory_System::Terminate() { std::ofstream file; std::stringstream ss; file.open("example.txt"); for ( int i = 0; i < item_count; i++) { Product *temp = static_cast <Product*> (ptr_inv_item[i]); file << temp->GetItemName() << ";" << temp->GetItemQuantity() << ";" << temp->GetProductPrice() << ";";
  • 6. switch (temp->GetProductCondition()) { case PC_DEFECTIVE: file << "Dn"; break ; case PC_NEW: file << "Nn"; break ; case PC_REFURBISHED: file << "Rn"; break ; case PC_USED: file << "Un"; break ; default : file << "Dn"; break ; } } } InventorySystem.h #ifndef InventorySystem_hpp #define InventorySystem_hpp #include "InventoryItem.hpp"
  • 7. #include "Product.hpp" #include <stdio.h> #include <string> class Inventory_System { public : Inventory_System(); Inventory_System(std::string, int ); ~Inventory_System(); int GetStoreId(); int GetItemCount(); std::string GetStoreName(); void BuildInventory(); void ShowInventory(); void ShowDefectInventory(); void Terminate(); private : std::string store_name; int store_id, item_count = 0; Inventory_Item **ptr_inv_item = new Inventory_Item*[512]; }; #endif /* InventorySystem_hpp */ InventoryItem.cpp #include "InventoryItem.hpp"
  • 8. #include <iostream> Inventory_Item::Inventory_Item(){ } Inventory_Item::Inventory_Item(std::string name, int quantity) : item_name(name), item_quantity(quantity) { } Inventory_Item::~Inventory_Item() { std::cout << "Inventory Item " << item_name << " with " << item_quantity << " item(s) destroyed.n"; } std::string Inventory_Item::GetItemName() const { return item_name; } int Inventory_Item::GetItemQuantity() const { return item_quantity; } void Inventory_Item::SetItemName(std::string name) { item_name = name; } void Inventory_Item::SetItemQuantity( int quantity) { item_quantity = quantity; } void Inventory_Item::Display() const {
  • 9. std::cout << item_name << " (" << item_quantity << ") "; } InventoryItem.h #ifndef InventoryItem_hpp #define InventoryItem_hpp #include <stdio.h> #include <string> class Inventory_Item { public : Inventory_Item(); Inventory_Item(std::string name, int quantity); ~Inventory_Item(); std::string GetItemName() const ; int GetItemQuantity() const ; void SetItemName(std::string); void SetItemQuantity( int ); virtual void Display() const ; protected : std::string item_name; int item_quantity; private : }; #endif /* InventoryItem_hpp */
  • 10. Product.cpp #include "Product.hpp" #include <iostream> #include <iomanip> Product::Product() : Inventory_Item(), product_id(0), product_price(0.0) { } Inventory_Item(), product_id(0), product_price(0.0){ } Product::Product(std::string name, int quantity) : Inventory_Item(name, quantity), product_id(rand()% 1000), product_price(100.0 * ((rand() + 1) / double (RAND_MAX + 2))){ } Product::~Product() { std::cout << "Product " << product_id << " priced $" << product_price << " has been destroyed."; } int Product::GetProductId() const { return product_id;
  • 11. } double Product::GetProductPrice() const { return product_price; } T_Condition Product::GetProductCondition() const { return condition_; } void Product::SetProductId( int id){ product_id = id; } void Product::SetProductPrice( double price) { product_price = price; } void Product::SetProductCondition(T_Condition condition) { condition_ = condition; } void Product::Display() const { Inventory_Item::Display(); std::cout << product_id << " $" << std::setprecision(4) << product_price << 'n'; } Product.h #ifndef Product_hpp #define Product_hpp
  • 12. #include "InventoryItem.hpp" #include <stdio.h> #include "Product.hpp" #include <string> typedef enum { PC_NEW, PC_USED, PC_REFURBISHED, PC_DEFECTIVE } T_Condition; class Product : public Inventory_Item { public : Product(); Product(std::string, int ); ~Product(); int GetProductId() const ; double GetProductPrice() const ; T_Condition GetProductCondition() const ; void SetProductId( int ); void SetProductPrice( double ); void SetProductCondition(T_Condition); virtual void Display() const ; private : T_Condition condition_; int product_id; double product_price; }; #endif /* Product_hpp */