Question: C++ Question on no operator < < matches these operands Okay in the void showCustomer (Customer c) section of my code, the first set of

C++ Question on no operator << matches these operands

Okay in the void showCustomer (Customer c) section of my code, the first set of << is coming up with the error message mentioned above. The rest are showing up as okay.

Also, I am getting a getline error on the getline(cin, c.firstNm) and getline(cin, c.street) lines. All other getlines are showing okay.

Here is my code.

#include

#include

using namespace std;

int index = 0; //variable to hold how many custers are entered

struct Address //Structure for the address.

{

string street;

string city;

string state;

string zipcode;

};

struct Customer //Stucture for the Customer

{

string firstNm, lastNm;

Address busAddr, homeAddr;

};

//Functions

int displayMenu();

Customer getCustomer();

void showCustomer(Customer);

void allCustomers(Customer[]);

Address getAddress();

void findCust(Customer[], int);

int main()

{

Customer cust[100];

while (true)

{

int choice = displayMenu();

switch (choice)

{

case 1:

cust[index] = getCustomer();

index++;

break;

case 2:

allCustomers(cust);

break;

case 3:

findCust(cust, index);

break;

case 4:

cout << "Exit program!!" << endl;

return 0;

break;

default:

cout << "Invald selection!!" << endl;

}

cout << endl;

}

return 0;

}

int displayMenu()

{

//Display menu.

cout << "1. Enter new customer. " << endl;

cout << "2. Display all customers. " << endl;

cout << "3. Display a particular customer. " << endl;

cout << "4. Exit the program. " << endl;

int choice; // User selects the option they want.

cout << "Enter choice: ";

cin >> choice;

cin.ignore();

cout << endl;

return choice; //Return choice displayed.

}

Address getAddress() { // User enters requested information.

Address a;

cout << "Enter Street: ";

getline(cin, a.street);

cout << "Enter City: ";

getline(cin, a.city);

cout << "Enter State: ";

getline(cin, a.state);

cout << "Enter Zip Code: ";

getline(cin, a.zipcode);

return a;

}

Customer getCustomer() // Enter first name, last name and two addresses and return the customer.

{

Customer c;

cout << "Enter First Name: ";

getline(cin, c.firstNm);

cout << "Enter Last Name: ";

getline(cin, c.lastNm);

cout << "Enter Business Address: " << endl;

c.busAddr = getAddress();

cout << " Enter Home Address: " << endl;

c.homeAddr = getAddress();

cout << endl;

return c;

}

void showCustomer(Customer c) {

cout << "First Name: " << c.firstNm << endl;

cout << "Last Name: " << c.lastNm << endl;

cout << "Business Address: " << c.busAddr.street << " , " << c.busAddr.city << " , " << c.busAddr.state << " , " << c.busAddr.zipcode << endl;

cout << "Home Address: " << c.homeAddr.street << " , " << c.homeAddr.city << " , " << c.homeAddr.state << " , " << c.homeAddr.zipcode << endl;

}

void allCustomers(Customer cust[]) {

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

showCustomer(cust[i]);

cout << endl;

}

}

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

// Ask user to enter first and last name

string firstName, lastName;

cout << "Enter First Name: ";

getline(cin, firstName);

cout << "Enter Last Name: ";

getline(cin, lastName);

cout << endl;

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

if (cust[i].firstNm == firstName && cust[i].lastNm == lastName) {

showCustomer(cust[i]);

return;

}

}

cout << "Customer not found!" << endl;

}

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!