I am creating a directory program that prompts a user for a file name and reads the file into a string array. I'm have trouble in my SearchFirstName function. I get an error:'std::string' has no member named 'userRecord'. I'm not sure how to fix this because userRecord is declared.
Header
#include<string>
using namespace std;
enum Title {Mr, Mrs, Ms, Dr, NA};
struct NameType {
Title title;
string firstName;
string lastName;
};
struct AddressType {
string street;
string city;
string state;
string zip;
};
struct PhoneType {
int areaCode;
int prefix;
int number;
};
struct entryType {
NameType name;
AddressType address;
PhoneType phone;
};
const int MAX_RECORDS = 50;
Code
// string bookArray[MAX_RECORDS];
entryType bookArray[MAX_RECORDS]; //Solution
int bookCount = 0;
void OpenFile(string& filename, ifstream& inData)
{
do {
cout << "Enter file name to open: ";
cin >> filename;
inData.open(filename.c_str());
if (!inData)
cout << "File not found!" << endl;
} while (!inData);
if(inData.is_open())
{
for(int i=0; i<MAX_RECORDS;i++)
{
inData>> bookArray[bookCount];
++bookCount;
}
}
}
void SearchFirstName(ifstream& inData)
{
entryType userRecord; // Declaration of userRecord
string searchName;
string normalSearchName, normalFirstName;
char choice;
bool found = false;
cout << "Enter first name to search for: ";
cin >> searchName;
for(int i = 0; i < bookCount; ++i){
normalFirstName = NormalizeString(bookArray[i].userRecord.name.firstName);
// Convert retrieved string to all uppercase
if (normalFirstName == normalSearchName) { // Requested name matches
PrintRecord(bookArray[i].userRecord.name.firstName);
cout << "Is this the correct entry? (Y/N)";
cin >> choice;
choice = toupper(choice);
cout << endl;
if (choice == 'Y') {
found = true;
break;
}
}
}
// Matching name was found before the end of the file
if (inData && !found){
cout << "Record found: " << endl;
PrintRecord(userRecord);
cout << endl;
}
else if (!found) // End of file. Name not found.
{
cout << searchName << " not found!" << endl << endl;
}
// Clear file fail state and return to beginning
inData.clear();
inData.seekg(0);
}
string bookArray[MAX_RECORDS];
bookArray is of type string.It should be
entryType bookArray[MAX_RECORDS];
Also
normalFirstName = NormalizeString(bookArray[i].userRecord.name.firstName);
bookArray[i] cannot have userRecord as a member.userRecord is variable that you have declared.
It should be
normalFirstName = NormalizeString(bookArray[i].name.firstName);
Related
I have a class Employees. I'm trying to make the user insert and delete an employee but it's not working. The size of the vectors should be 500.
class Employees{
public:
int maxx = 500;
vector<string> Surname;
vector<string> FirstName;
vector<string> birthdate;
int vacation[500];
public:
Employees() : Surname(500) {}
};
This is the function that inserts, but printing elements of the vectors is not working at all:
void Process(Employees ZZ){
string dateyear;
string datemonth;
string dateday;
int dateyear1;
int datemonth1;
int dateday1;
int Realage;
int Vacationi = 0;
for(int i = 0; i < 500; i++) {
string s;
cin >> s;
string d;
cin >> d;
string c;
cin >> c;
ZZ.Surname.push_back(s);
ZZ.FirstName.push_back(d);
ZZ.birthdate.push_back(c);
cout << endl << ZZ.Surname[1] << endl;
}
Now the delete function, if I input a string then search for it in the vector then get his index then delete, but the vector doesn't update any values.
void DeleteEmployee(Employees ZZ){
cout<< endl << ZZ.Surname[1] << endl ;
for (int i = 0; i < ZZ.Surname.size(); i++){
cout << ZZ.Surname[i] ;
}
cout << " delete employee";
string delete1;
cin >> delete1;
auto it = std::find(ZZ.Surname.begin(), ZZ.Surname.end(), delete1);
if (it == ZZ.Surname.end())
{
cout<< " name not in vector " << endl;
}
else
{
//auto index = distance(Names.begin(), find(Names.begin(), Names.end(), old_name_)));
//ZZ.Surname.erase(ZZ.Surname.begin()+index) ;
}
}
This is the main function, also the values of the vector are not printing:
int main()
{
Employees ZZ;
Process(ZZ);
DeleteEmployee(ZZ);
cout << "fyccck";
for (int i = 0; i < ZZ.Surname.size(); i++){
cout << ZZ.Surname[i] ;
}
}
There are a lot of things wrong with this code. But the particular issue you are asking about is caused by your functions passing the Employees object by value, so a copy is made, and any changes you make to the copy are not reflected in the original object in main().
You need to change the parameters to pass the Employees object by reference instead:
void Process(Employees &ZZ)
void DeleteEmployee(Employees &ZZ)
That being said, the whole design of the code is not good in general. The vectors are not being kept in sync properly, and for that matter you are using more vectors then you actually need, 1 single vector will suffice. And Process() and DeleteEmployee() should be members of the Employees class, not separate functions. And they are both accessing out-of-bounds of the Surname vector.
I would suggest completely rewriting the code from scratch, for instance something more like this:
struct Employee{
string Surname;
string FirstName;
string BirthDate;
int Vacation;
string DisplayName() const { return Surname + ", " + FirstName; }
};
class Employees{
public:
static const int maxx = 500;
vector<Employee> employees;
Employees() { employees.reserve(maxx); }
bool Add(const Employee &e);
bool Delete(string Surname, string FirstName);
};
bool Employees::Add(const Employee &e) {
if (employees.size() < maxx) {
employees.push_back(e);
return true;
}
return false;
}
bool Employees::Delete(string Surname, string FirstName) {
auto it = std::find_if(employees.begin(), employees.end(),
[&](const Employee &e){
return e.Surname == Surname && e.FirstName == FirstName;
}
);
if (it != employees.end()) {
employees.erase(it);
return true;
}
return false;
}
int main()
{
Employees ZZ;
for(int i = 0; i < Employees::maxx; ++i) {
Employee e;
cin >> e.Surname;
cin >> e.FirstName;
cin >> e.BirthDate;
e.Vacation = 0;//cin >> e.Vacation;
ZZ.Add(e);
cout << endl << e.DisplayName() << endl;
}
cout << " delete employee";
string Surname, FirstName;
if (cin >> Surname >> FirstName) {
if (ZZ.Delete(Surname, FirstName)) {
cout << " name deleted from vector " << endl;
} else {
cout << " name not in vector " << endl;
}
}
cout << "fyccck";
for (auto &e : ZZ.employees) {
cout << e.DisplayName() << endl;
}
return 0;
}
Throwing this out there first I'm a still learning how to program in school. I'm having an issue reading in to a dynamically created array with a pointer to one of my classes. The function readClassArray() isn't getting the variable back from student.getCreditNumber. The program complies fine in Visual Studio but when I get the the readClassArray it just skips over the function because s.getCreditNumber returns 0.
#ifndef STUDENT_H
#define STUDENT_H
#include <iostream>
using namespace std;
class Courses{
private:
int courseNumber;
double hours;
string courseName;
char grade;
public:
void setCourseNumber(int n){courseNumber = n; }
void setCreditHours(double c) { hours = c; }
void setCourseName(string n) { courseName = n; }
void setGrade(char g) { grade = g; }
int getCourseNumber() { return courseNumber; }
double getCreditHours() { return hours; }
string getCourseName() { return courseName; }
char getGrade() { return grade; }
};
class Student : public Courses{
private:
string firstName;
string lastName;
string studentNumber;
int creditNumber;
double gpa;
public:
Courses * courses;
Student() {
firstName = " ";
lastName = " ";
studentNumber = " ";
creditNumber = 0;
gpa = 0.0;
courses = NULL;
}
~Student() {
delete[] courses;
};
void setFirstName(string n) { firstName = n; }
void setLastName(string l) { lastName = l; }
void setStudentNumber(string a) { studentNumber = a; }
void setCreditNumber(int num) { creditNumber = num; }
string getFirstName() { return firstName; }
string getLastName() { return lastName; }
string getStudentNumber() { return studentNumber; }
int getCreditNumber() { return creditNumber; }
};
#endif
Student.cpp
#include "Student.h"
#include <iostream>
#include <string>
using namespace std;
void readStudent();
void readCourseArray();
void computeGPA();
void printSummary();
void readStudent() {
Student a;
string number;
string firstName;
string lastName;
int courses;
cout << "Enter student number: ";
cin >> number;
a.setStudentNumber(number);
cout << "Enter student first name: ";
cin >> firstName;
a.setFirstName(firstName);
cout << "Enter student last name: ";
cin >> lastName;
a.setLastName(lastName);
cout << "Enter student number of courses: ";
cin >> courses;
a.setCreditNumber(courses);
cout << "\n"; }
void readCourseArray(){
Student s;
s.courses = new Courses[s.getCreditNumber()];
int num;
double cHours;
string cName;
char grade;
cout << "test" << endl;
for (int i = 0; i < s.getCreditNumber(); i++){
cout << "Enter class " << i + 1 << " number: ";
cin >> num;
s.courses[i].setCourseNumber(num);
cout << "Enter class " << i + 1 << " name: ";
cin >> cName;
s.courses[i].setCourseName(cName);
cout << "Enter class " << i + 1 << " hours: ";
cin >> cHours;
s.courses[i].setCreditHours(cHours);
cout << "Enter class " << i + 1 << " grade: ";
cin >> grade;
s.courses[i].setGrade(grade);
cout << "\n";
}
}
At the start of readCourseArray you've created s. When that happens the value of the creditNumber member is 0 as set by the default constructor. You need to do something to set it to a non-zero value. If you're expecting the value set in readStudent to carry over you need to plumb the two functions together. Either pass in a Student object as a reference to each function, or have readStudent return a Student object and pass that to readCourseArray.
I'm creating an address book program that allow user to search by first name, last name,phone number and address. The user is prompted to enter a file name and the file is read into an array. I'm having trouble modifying by existing SearchFirstName function to loop through array. I have read over this topic multiple times I'm just not understanding it. Any help would be greatly appreciated.
File
Susan, Smith, 123 456 789
101 Main Street
Bob, Smith, 567 345 9076
456 Market Street
Header File
#include<string>
using namespace std;
enum Title {Mr, Mrs, Ms, Dr, NA};
struct NameType {
Title title;
string firstName;
string lastName;
};
struct AddressType {
string street;
string city;
string state;
string zip;
};
struct PhoneType {
int areaCode;
int prefix;
int number;
};
struct entryType {
NameType name;
AddressType address;
PhoneType phone;
};
const int MAX_RECORDS = 50;
struct addressBookType {
entryType record[MAX_RECORDS];
int numEntries;
};
Code
string bookArray[MAX_RECORDS];
int main()
{
entryType userRecord;
string filename;
ifstream inData;
char searchOption;
OpenFile(filename, inData);
MainMenu(inData, filename);
return 0;
}
void OpenFile(string& filename, ifstream& inData)
{
do {
cout << "Enter file name to open: ";
cin >> filename;
inData.open(filename.c_str());
if (!inData)
cout << "File not found!" << endl;
} while (!inData);
if(inData.is_open())
{
for(int i=0; i<MAX_RECORDS;i++)
{
inData>> bookArray[i];
}
}
}
// Searches passed file stream for a first name read from the user
void SearchFirstName(ifstream& inData)
{
string searchName;
entryType userRecord;
string normalSearchName, normalFirstName;
char choice;
bool found = false;
cout << "Enter first name to search for: ";
cin >> searchName;
normalSearchName = NormalizeString(searchName); // Convert name to all uppercase
// Loop through all records in the file
while (GetRecord(inData, userRecord)){
normalFirstName = NormalizeString(userRecord.name.firstName); // Convert retrieved string to all uppercase
if (normalFirstName == normalSearchName) { // Requested name matches
PrintRecord(userRecord);
cout << "Is this the correct entry? (Y/N)";
cin >> choice;
choice = toupper(choice);
cout << endl;
if (choice == 'Y') {
found = true;
break;
}
}
}
// Matching name was found before the end of the file
if (inData && !found){
cout << "Record found: " << endl;
PrintRecord(userRecord);
cout << endl;
}
else if (!found) // End of file. Name not found.
{
cout << searchName << " not found!" << endl << endl;
}
// Clear file fail state and return to beginning
inData.clear();
inData.seekg(0);
}
My attempt
void SearchFirstName(ifstream& inData)
{
string searchName;
entryType userRecord;
cout << "Enter first name to search for: ";
cin >> searchName;
string newSearchName = NormalizeString(searchName);
string upFirst = NormalizeString(userRecord.name.firstName);
for (int i=0;i<MAX_RECORDS;i++)
{
while(newSearchName == upFirst)
{
if (bookArray[i]== upFirst)
{
cout<<"Name Found";
cout <<bookArray[i]; //test case
}
}
}
}
Create your array, in this case it'll be an std::vector because that is more simple to use, by running your GetRecord function inside of a while loop and appending the result to the vector w/vector_variable_name.push_back(NormalizeString(value_returned_from_GetRecord));. The NormalizeString part is so you don't have to call it billions of times later.
Pass in your array like so void SearchFirstName(std::vector<entryType> *in_data_arr>)
Change your while loop to a for loop: for (int i = 0; i < in_data_arr.size(); i++) {
Inside the loop change normalSearchName = NormalizeString(searchName); to normalSearchName = in_data_arr[i].name.firstName;
And from there it should generally be identical.
Please, how to fix this code
[Error] a function-definition is not allowed here before '}' token
[Error] expected '}' at the end of input
I don't know what's the problem with my code even though I've already checked the compiler errors
#include<iostream>
using namespace std;
struct name_type
{
string first,middle,last;
};
struct SD
{
name_type name;
float grade;
};
const int MAX_SIZE = 35;
int isFull(int last) {
if(last == MAX_SIZE - 1) {
return(1);
}
else {
return(0);
}
}
int isEmpty(int last) {
if(last < 0) {
return(1);
}
else {
return(0);
}
}
main()
{
SD SD2[MAX_SIZE];
int last = -1;
if(isEmpty(last))
{
cout << "List is empty\n";
}
for (int a=0; a <35; a++)
{
cout << "Enter first name:.....";
cin >> SD2[a].name.first;
cout << "Enter middle name:....";
cin >> SD2[a].name.middle;
cout << "Enter last name:......";
cin >> SD2[a].name.last;
cout << "Enter your grade:.....";
cin >> SD2[a].grade;
cout << '\n';
}
system("cls");
cout << "1 - Add";
cout << "2 - Delete";
cout << "3 - Search";
cout << "4 - Print";
cout << "5 - Exit";
string lname, fname;
int choice, search;
cin >> choice;
if(choice == 3) {
cin >> fname;
cin >> lname;
int index = search;
(SD2, lname, fname, last);
if (index > 0) {
cout << "ERROR\n";
}
else {
cout << "The grade of " << lname << "," << fname << "is " << SD2[index].grade;
}
}
int search(SD list [], string search_lname, string search_fname, int last) {
int index;
if(isEmpty(last)==1) {
cout << "\nThe list is Empty!";
}
else {
index = 0;
while(index!= last+1 && list[index].name.first != search_fname && list[index].name.last != search_lname) {
++index;
}
if(index != last + 1) {
cout << "\nItem Requested is Item" << index + 1 << ".";
return index;
}
else {
cout << "\n Item Does Not Exist.";
}
}
return -1; // list is empty or search item does not exist
}
}
One of the problems is in your declaration of the main function:
main()
In c++, the main() function must have a return type of int. Sin you have not specified any data type for the return value of main(), it sets the return data type to void, which is produces the error just before main(). To learn and understand more about main() for C++, visit the following link Main Function.
To sort this, change the above line of code to:
int main() // notice that the return type here is int. This is required in c++
Another thing: in these lines:
int index = search;
(SD2, lname, fname, last);
Over here, you want to pass SD2, lname, fname and last to the search() function. However, your syntax is wrong. The function and its parameters when called cannot be split by a semicolon, because a semicolon terminates the statement. Therefore, the compiler sees search as a variable, not a function. This along with the statement following it cause the error. You should change those 2 lines to:
int index = search(SD2, lname, fname, last); // this is proper syntax to call a function.
Also, you need to take out search() from inside the main() function and place it above the main() function. That is also causing an error.
Ok, I'm working on this inventory program, in which what is supposed to happen is the user inputs various bits of information about a particular product, then it gets passed to the inventory, while giving the user the opportunity to change stuff (as you should see in the code). Since I'm doing this for a school project, I have to have the various classes that are there (hence why I haven't gotten rid of them.
Now my issue is with the vectors in class Inventory.
Error 'std::vector> AddProduceToInventory(std::vector<_Ty,std::allocator<_Ty>>)': cannot convert argument 1 from 'std::vector>' to 'std::vector>'
This issue applies to each of those vectors in the class. I only copied one of the identical errors.
I can't figure out what else I'm supposed to do. Here is my code (sorry for the length!)
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
class Item {
public:
void SetPrice(int prcInDllrs) {
priceInDollars = prcInDllrs; // Somehow I need to keep adding each of these totals to make a grand total price.
}
void SetItemPrice(int whatever) {
itemsPrice = whatever;
}
void SetName(string nm)
{
name = nm;
};
void SetQuantity(int qnty)
{
quantity = qnty;
};
virtual void Print() //Here is my print problem
{
};
virtual ~Item()
{
return;
};
protected:
string name;
int quantity = 0;
int priceInDollars = 0;
int itemsPrice = 0;
};
class Produce : public Item { // Derived from Item class
public:
void SetExpiration(string expir)
{
expiration = expir;
};
void Print()
{
cout << name << " x" << quantity
<< " (Expires: " << expiration << ")" << " for $" << itemsPrice //FILL THIS IN!!!
<< endl;
};
private:
string expiration;
};
class Book : public Item {
public:
void SetAuthor(string athr) {
author = athr;
}
void Print()
{
cout << name << " x" << quantity
<< " for $" << itemsPrice << " (Author: " << author << ")" << endl;
}
private:
string author;
};
class Inventory {
public:
void PrintInventory()
{
if (inventory.size() == 0) {
cout << "No items to print." << endl;
}
else {
for (unsigned int i = 0; i < inventory.size(); ++i) {
cout << i << " - ";
inventory.at(i)->Print();
}
}
cout << "Total inventory value: $" << totalInvPriceInDollars << endl;
}
//I am leaving these out of the equation until I get the PrintInventory working
void AddItemToInventory()
{
vector<Inventory*> AddProduceToInventory(vector<Inventory*> Invntry);
AddProduceToInventory(vector<Inventory*> inventory)
{
Produce* prdc;
string usrInptName = "";
string usrInptQntyStr = "";
istringstream inSS;
int usrInptQnty = 0;
string usrInptExpr = "";
string usrInptPrcStr = "";
int usrInptPrc = 0;
int itemsTotalPrice = 0;
istringstream inDD;
string runningTotal = "";
int sum = 0;
cout << "Enter name of new produce: ";
getline(cin, usrInptName);
cout << "Enter quantity: ";
getline(cin, usrInptQntyStr);
inSS.str(usrInptQntyStr);
inSS >> usrInptQnty;
inSS.clear();
cout << "Enter expiration date: ";
getline(cin, usrInptExpr);
cout << "Enter the price per item: $";
getline(cin, usrInptPrcStr);
inDD.str(usrInptPrcStr);
inDD >> usrInptPrc;
inDD.clear();
itemsTotalPrice = usrInptPrc * usrInptQnty;
prdc = new Produce;
prdc->SetName(usrInptName);
prdc->SetQuantity(usrInptQnty);
prdc->SetExpiration(usrInptExpr);
prdc->SetPrice(usrInptPrc);
prdc->SetItemPrice(usrInptPrc);
inventory.push_back(prdc);
Inventory set;
set.SetInventory(inventory);
return inventory;
}
}
void AddBookToInventory()
{
vector<Inventory*> AddBookToInventory(vector<Inventory*> inventory) {
Book* prdct;
string usrInptName = "";
string usrInptQntyStr = "";
istringstream inSS;
int usrInptQnty = 0;
string usrInptAthr = "";
string usrInptPrcStr = "";
int usrInptPrc = 0;
int itemsTotalPrice = 0;
istringstream inDD;
string runningTotal = "";
int sum = 0;
cout << "Enter name of new book: ";
getline(cin, usrInptName);
cout << "Enter quantity: ";
getline(cin, usrInptQntyStr);
inSS.str(usrInptQntyStr);
inSS >> usrInptQnty;
inSS.clear();
cout << "Enter author: ";
getline(cin, usrInptAthr);
cout << "Enter the price per item: $";
getline(cin, usrInptPrcStr);
inDD.str(usrInptPrcStr);
inDD >> usrInptPrc;
inDD.clear();
prdct = new Book;
prdct->SetName(usrInptName);
prdct->SetQuantity(usrInptQnty);
prdct->SetPrice(usrInptPrc);
prdct->SetAuthor(usrInptAthr);
prdct->SetItemPrice(usrInptPrc);
inventory.push_back(prdct);
Inventory set;
set.SetInventory(inventory);
return inventory;
}
}
void UpdateItemQtyInventory()
{
//This is the update function in which we can change how many items a certain purchase has
vector<Item*> UpdateItemQtyInInventory(vector<Item*> inventory) {
string usrIndexChoiceStr = "";
unsigned int usrIndexChoice = 0;
istringstream inSS;
string usrInpuQntyStr = "";
int usrInptQnty = 0;
if (inventory.size() == 0) {
cout << "No items to update." << endl;
}
else {
PrintInventory(inventory);
do {
cout << "Update which item #: ";
getline(cin, usrIndexChoiceStr);
inSS.str(usrIndexChoiceStr);
inSS >> usrIndexChoice;
inSS.clear();
} while (!(usrIndexChoice < inventory.size()));
cout << "Enter new quantity: ";
std::getline(cin, usrInptQntyStr);
inSS.str(usrInptQntyStr);
inSS >> usrInptQnty;
inSS.clear();
inventory.at(usrIndexChoice)->SetQuantity(usrInptQnty);
}
return inventory;
}
}
void RemoveItemFromInventory()
{
//Here we will be removing an entire item from the inventory
vector<Item*> RemoveItemFromInventory(vector<Item*> inventory) {
istringstream inSS;
string usrIndexChoiceStr = "";
unsigned int usrIndexChoice = 0;
string usrInptQntyStr = "";
if (inventory.size() == 0) {
cout << "No items to remove." << endl;
}
else {
PrintInventory(inventory);
do {
cout << "Remove which item #: ";
getline(cin, usrIndexChoiceStr);
inSS.str(usrIndexChoiceStr);
inSS >> usrIndexChoice;
inSS.clear();
} while (!(usrIndexChoice < inventory.size()));
inventory.erase(inventory.begin() + usrIndexChoice);
}
return inventory;
}
}
void GetTotalValueAsPrice()
{
}
void SetInventory(vector<Item*> invntry) {
inventory = invntry;
}
private:
int totalInvPriceInDollars = 0;
vector<Inventory*> inventory;
};
// Print all items in the inventory
void PrintInventory(vector<Item*> inventory);
// Dialogue to create a new item, then add that item to the inventory
vector<Item*> AddItemToInventory(vector<Item*> inventory);
// Dialogue to create a new book, then add that book to the inventory
vector<Item*> AddBookToInventory(vector<Item*> inventory);
// Dialogue to update the quantity of an item, then update that item in the inventory
vector<Item*> UpdateItemQtyInInventory(vector<Item*> inventory);
// Dialogue to remove a specific item, then remove that specific item from the inventory
vector<Item*> RemoveItemFromInventory(vector<Item*> inventory);
int main() {
vector<Inventory*> inventory1;
string usrInptOptn = "default";
string usrInptOptn2 = "default";
Inventory update;
update.UpdateItemQtyInventory();
while (true) {
// Get user choice
cout << "\nEnter (p)rint, (a)dd, (u)pdate, (r)emove, or (q)uit: ";
getline(cin, usrInptOptn);
// Process user choice
if (usrInptOptn.size() == 0) {
continue;
}
else if (usrInptOptn.at(0) == 'p') {
Inventory printer;
printer.PrintInventory();
update.SetInventory(inventory1);
}
else if (usrInptOptn.at(0) == 'a') {
cout << "\nEnter (b)ook or (p)roduce: ";
getline(cin, usrInptOptn2);
if (usrInptOptn2.at(0) == 'b') {
inventory1 = AddBookToInventory(inventory1);
inventoryUpdate.SetInventory(inventory1);
}
else if (usrInptOptn2.at(0) == 'p') {
inventory1 = AddItemToInventory(inventory1);
inventoryUpdate.SetInventory(inventory1);
}
else
{
continue;
}
}
else if (usrInptOptn.at(0) == 'u') {
inventory1 = UpdateItemQtyInInventory(inventory1);
}
else if (usrInptOptn.at(0) == 'r') {
inventory1 = RemoveItemFromInventory(inventory1);
}
else if (usrInptOptn.at(0) == 'q') {
cout << "\nGood bye." << endl;
break;
}
}
return 0;
}
I'm also getting additional errors, but I think they are coming from this main issue. What do I do to fix this?
Thanks!
Also, I'm using Visual Studio, but have checked with Code::Blocks to make sure it isn't a weird compiler issue.
Most of your functions look somehow similar to this:
void foo() {
std::vector<T> foo(std::vector<T> bar){
/*...*/
}
}
It looks like you try to declare a function inside the function (with the same name but different parameters and return type and sometimes with missing return type). Just dont do that, but just this:
std::vector<T> foo(std::vector<T> bar){
/*...*/
}