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)
code below
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 (1).pdf

More Related Content

Similar to Why won't my code build and run- and what is the correct code so it bu (1).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
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
Fred Chien
 
Threads and Callbacks for Embedded Python
Threads and Callbacks for Embedded PythonThreads and Callbacks for Embedded Python
Threads and Callbacks for Embedded Python
Yi-Lung Tsai
 
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
 
Android ndk
Android ndkAndroid ndk
Android ndk
Khiem-Kim Ho Xuan
 
CPP Programming Homework Help
CPP Programming Homework HelpCPP Programming Homework Help
CPP Programming Homework Help
C++ Homework Help
 
Lecture2.ppt
Lecture2.pptLecture2.ppt
Lecture2.ppt
TarekHemdan3
 
OpenCMIS Part 1
OpenCMIS Part 1OpenCMIS Part 1
OpenCMIS Part 1
Alfresco Software
 
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
bradburgess22840
 
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
aassecuritysystem
 
#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
AASTHA76
 
Introduction to Spring Boot.pdf
Introduction to Spring Boot.pdfIntroduction to Spring Boot.pdf
Introduction to Spring Boot.pdf
ShaiAlmog1
 
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 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
anubhavnigam2608
 
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
ssuser454af01
 
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
abiwarmaa
 
Develop an inventory management system for an electronics store. The .pdf
Develop an inventory management system for an electronics store. The .pdfDevelop an inventory management system for an electronics store. The .pdf
Develop an inventory management system for an electronics store. The .pdf
flashfashioncasualwe
 

Similar to Why won't my code build and run- and what is the correct code so it bu (1).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++
 
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
 
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#
 
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
 
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
 
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
 
C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
#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
 
Introduction to Spring Boot.pdf
Introduction to Spring Boot.pdfIntroduction to Spring Boot.pdf
Introduction to Spring Boot.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?
 
V8
V8V8
V8
 
#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
 
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
 
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
 
Develop an inventory management system for an electronics store. The .pdf
Develop an inventory management system for an electronics store. The .pdfDevelop an inventory management system for an electronics store. The .pdf
Develop an inventory management system for an electronics store. The .pdf
 

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.pdf
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 
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
umeshagarwal39
 

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

South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 

Recently uploaded (20)

South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 

Why won't my code build and run- and what is the correct code so it bu (1).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) code below 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 */