Hi I am using Repl.it, could anyone help fix the errors?
Instruction:
main.cpp
#include <iostream>
#include <cstdlib>
#include "InvItem.h"
using namespace std;
int main() {
InvItem a;
string description, idNumber;
// read in two strings
getline(cin, description);
getline(cin, idNumber);
// store properties in the object
a.setDescription(description);
a.setIDNumber(idNumber);
// print out the properties of the object
cout << a.getDescription() << endl;
cout << a.getIDNumber() << endl;
}
---------------------------------------------------------------
invltem.h
#ifndef INVITEM_H
#define INVITEM_H
#include<string>
using std::string;
class InvItem
{
public:
InvItem();
void setDescription(string desc);
void setIDNumber(string id);
string getDescription() const;
string getIDNumber() const;
private:
string desc;
string id;
};
#endif
---------------------------------------------------------------
invltem.cpp
#include "InvItem.h"
#include<string>
using std::string;
InvItem::InvItem(): desc(""), id(""){}
void InvItem::setDescription(string desc){
this->desc =desc;
}
void InvItem::setIDNumber(string id){
this->id=id;
}
string InvItem::getDescription() const{return desc;}
string InvItem::getIDNumber() const{return id;}
---------------------------------------------------------------
Errors:
clang version 7.0.0-3~ubuntu0.18.04.1 (tags/RELEASE_700/final)
exit status 1
invItem.cpp:1:10: fatal error: 'InvItem.h' file not found
#include "InvItem.h"
^~~~~~~~~~~
1 error generated.
main.cpp:3:10: fatal error: 'InvItem.h' file not found
#include "InvItem.h"
^~~~~~~~~~~
1 error generated.
Dear student your code is correct but only one small mistake you have made.
Your mistake is the filename in #include statement.
Your header file name is invltem.h but in you code you have written #include "Invltem.h" (the I should be lowercase)
Change your include line to #include "invltem.h" in both files
Please do the above change in include statements and try running your code.
If you face any more errors then let me know in comment section.
-----------------------------------------------------------------------
CODE Screenshots



-------------------------------------------------------------------------------------------------------------------
OUTPUT
-------------------------------------------------------------------
Please rate the answer if this helped you,
Thank you
Hi I am using Repl.it, could anyone help fix the errors? Instruction: main.cpp #include <iostream> #include...
CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer; cout << "MENU" << endl; cout << "a - Add item to cart" << endl; cout << "d - Remove item from cart" << endl; cout << "c - Change item quantity" << endl; cout << "i - Output items' descriptions" << endl; cout << "o - Output shopping cart" << endl; cout << "q - Quit" << endl << endl; while (true) {...
The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...
I need help with this assignment, can someone HELP ? This is the assignment: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt) Public member functions SetDescription() mutator & GetDescription() accessor (2 pts) PrintItemCost() - Outputs the item name followed by...
Who could write the array.cpp file ? //main.cpp #include "array.hpp" #include <iostream> int main() { int n; std::cin >> n; array a(n); for (int i = 0; i < n; i++) { std::cin >> a.data()[i]; } std::cout << "array size:" << a.max_size() << std::endl; std::cout << "array front:" << a.front() << std::endl; std::cout << "array back:" << a.back() << std::endl; int* data = a.data(); std::cout << "array elements using data:" << std::endl; for (int i = 0; i < n;...
employee.h
----------
#include <stdio.h>
#include <iostream>
#include <fstream>
class Employee {
private:
int employeeNum;
std::string name;
std::string address;
std::string phoneNum;
double hrWage, hrWorked;
public:
Employee(int en, std::string n, std::string a, std::string pn,
double hw, double hwo);
std::string getName();
void setName(std::string n);
int getENum();
std::string getAdd();
void setAdd(std::string a);
std::string getPhone();
void setPhone(std::string p);
double getWage();
void setWage(double w);
double getHours();
void setHours(double h);
double calcPay(double a, double b);
static Employee read(std::ifstream& in);
void write(std::ofstream& out);
};
employee.cpp
----------
//employee.cpp
#include...
The code will not run and I get the following errors in Visual Studio. Please fix the errors. error C2079: 'inputFile' uses undefined class 'std::basic_ifstream<char,std::char_traits<char>>' cpp(32): error C2228: left of '.open' must have class/struct/union (32): note: type is 'int' ): error C2065: 'cout': undeclared identifier error C2065: 'cout': undeclared identifier error C2079: 'girlInputFile' uses undefined class 'std::basic_ifstream<char,std::char_traits<char>>' error C2440: 'initializing': cannot convert from 'const char [68]' to 'int' note: There is no context in which this conversion is possible error...
PLEASE HELP WITH THE FIX ME'S #include #include #include #include "CSVparser.hpp" using namespace std; //============================================================================ // Global definitions visible to all methods and classes //============================================================================ // forward declarations double strToDouble(string str, char ch); // define a structure to hold bid information struct Bid { string bidId; // unique identifier string title; string fund; double amount; Bid() { amount = 0.0; } }; //============================================================================ // Linked-List class definition //============================================================================ /** * Define a class containing data members and methods to *...
Can you tell me what is wrong and fix this code. Thanks #include <iostream> #include <string> #include <fstream> #include <sstream> using namespace std; //function void displaymenu1(); int main ( int argc, char** argv ) { string filename; string character; string enter; int menu1=4; char repeat; // = 'Y' / 'N'; string fname; string fName; string lname; string Lname; string number; string Number; string ch; string Displayall; string line; string search; string found; string document[1000][6]; ifstream infile; char s[1000];...
please help me fix the error in here #include<iostream> #include <string> using namespace std; string getStudentName(); double getNumberExams(); double getScoresAndCalculateTotal(double E); double calculateAverage(double n, double t); char determineLetterGrade(); void displayAverageGrade(); int main() { string StudentName; double NumberExam, Average, ScoresAndCalculateTotal; char LetterGrade; StudentName = getStudentName(); NumberExam = getNumberExams(); ScoresAndCalculateTotal= getScoresAndCalculateTotal(NumberExam); Average = calculateAverage(NumberExam, ScoresAndCalculateTotal); return 0; } string getStudentName() { string StudentName; cout << "\n\nEnter Student Name:"; getline(cin, StudentName); return StudentName; } double getNumberExams() { double NumberExam; cout << "\n\n Enter...
*HOW DO I CHANGE THIS FROM A VOID FUNCTION TO A NON-VOID WITH PARAMETERS?* #include<iostream> #include<fstream> #include<string> using namespace std; void studentStats() { ifstream inputFile; inputFile.open("outFile.txt"); string studentData; string studentID; string ID, exam1, exam2, exam3; string header; cout << "Enter a Student ID: "; cin >> studentID; bool found =false; while (inputFile) { inputFile >> ID; inputFile >> exam1; inputFile >> exam2; inputFile >> exam3; if (ID.compare(studentID)==0) { cout << ID << " " << exam1 << " " <<...