Question: How to fix this error? error C2678: binary '==': no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable

How to fix this error?

error C2678: binary '==': no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion). The error is in Customer, see bold text below.

#include "MyDataStore.h"

#include "Customer.h"

#include "Book.h"

#include

#include

MyDataStore* MyDataStore::iInstance;

//declare private customer array

Customer customers[5];

//customer list prototype

void getCustomerList(Customer[], int);

MyDataStore::MyDataStore()

{

getCustomerList(customers, 5);

}

MyDataStore* MyDataStore::GetInstance()

{

if (iInstance == NULL) {

iInstance = new MyDataStore();

}

return iInstance;

}

void MyDataStore::getBooks(Book books[], int size) {

ifstream input;

input.open("text.txt");

string ISBN, title, author;

double price = 0.0;

int i = 0;

while (!input.eof()) {

input >> title;

input >> author;

input >> ISBN;

input >> price;

Book b = Book(title, author,ISBN, price);

if (i < size) {

books[i] = b;

i++;

}

}

}

Customer MyDataStore::getCustomer(int customerId) {

int numCustomers = 5;

for (int i = 0; i < numCustomers; ++i) {

if (customers[i].getCustID() == customerId) {

return customers[i];

}

}

}

void getCustomerList(Customer cust[], int size) {

ifstream input;

input.open("customer.txt");

string custID, firstName, lastName, address;

int i = 0;

while (!input.eof()) {

input >> custID;

input >> firstName;

input >> lastName;

input >> address;

Customer c = Customer(custID, firstName, lastName, address);

if (i < size) {

cust[i] = c;

i++;

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!