473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Error when compiling

im trying to make a restaurant menu program but i keep getting

"expected constructor, destructor, or type conversion before '<<' token" when i compile. any all would be much appreciated



/*
Name: Paul Pee
Date: 2/11/12
Description: Breakfast Programs
*/
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

struct menuItem
{
string menuChoice;
double menuPrice;
};

struct selectedItem
{
string menuChoice;
double menuPrice;
};



void getData(menuItem menuList[7]) //Loading data into the struct
{
menuList[0].menuChoice="Plain Egg";
menuList[0].menuPrice = 1.45;

menuList[1].menuChoice = "Bacon and Egg";
menuList[1].menuPrice = 2.45;

menuList[2].menuChoice = "Muffin";
menuList[2].menuPrice = 0.99;

menuList[3].menuChoice = "French Toast";
menuList[3].menuPrice = 1.99;

menuList[4].menuChoice = "Cereal";
menuList[4].menuPrice = 1.69;

menuList[5].menuChoice = "Coffee";
menuList[5].menuPrice = 1.25;

menuList[6].menuChoice = "Tea";
menuList[6].menuPrice = 1.25;
}

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void showMenu(menuItem menuList[7]) //function shows a customer to select items from the menu
{
cout << "What would you like for breakfast?"<<endl;

for (int i=0;i<7;i++)
{
cout << i+1 << ": " << left << setw(18) <<menuList[i].menuChoice << right << setw(14) << menuList[i].menuPrice << endl;
}

cout<<"Hit 0 to complete your order" << endl;
}

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

double iTotal ( double price , int amt)
{
double sp;
sp = price * amt;
return (sp);
}

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void printCheck(menuItem menuList[7])
{
int amt;
double price;
double eggtotal, mtotal, betotal, cetotal, cototal, fttotal, ttotal =0;
double total = 0.0;
int amtegg, amtbe, amtm, amtft, amtce, amtco, amtt = 0;
int choice = 9;
double tax = 0.05;
double pretotal = eggtotal + betotal + mtotal + fttotal + cetotal + cototal +ttotal;
double taxamt = pretotal * tax;
double fnltotal = pretotal + tax;

selectedItem selectedChoice[7];
for(int e=0;e<7;e++)
{
selectedChoice[e].menuChoice=' ';
selectedChoice[e].menuPrice=0;
}

cout << "Please make your selections." << endl;

while (choice != 0)
cin >> choice;

switch(choice)
{
case 1:
cout << setw(53)<< menuList[0].menuChoice <<" " << menuList[0].menuPrice<<endl;

if (amtegg == 0)
{
selectedChoice[0].menuPrice=menuList[0].menuPrice;
selectedChoice[0].menuChoice=menuList[0].menuChoice;
amtegg++;
}
else
amtegg++;

price = menuList[0].menuPrice;
amt = amtegg;
eggtotal = iTotal (price, amt);
break;

case 2:
cout << setw(53)<< menuList[1].menuChoice <<" " << menuList[1].menuPrice<<endl;

if (amtbe == 0)
{
selectedChoice[1].menuPrice=menuList[1].menuPrice;
selectedChoice[1].menuChoice=menuList[1].menuChoice;
amtbe++;
}
else
amtbe++;

price = menuList[1].menuPrice;
amt = amtbe;
betotal = iTotal (price, amt);
break;

case 3:
cout << setw(53)<< menuList[2].menuChoice <<" " << menuList[2].menuPrice<<endl;

if (amtm == 0)
{
selectedChoice[2].menuPrice=menuList[2].menuPrice;
selectedChoice[2].menuChoice=menuList[2].menuChoice;
amtm++;
}
else
amtm++;

price = menuList[2].menuPrice;
amt = amtm;
mtotal = iTotal (price, amt);
break;

case 4:
cout << setw(53)<< menuList[3].menuChoice <<" " << menuList[3].menuPrice<<endl;

if (amtft == 0)
{
selectedChoice[3].menuPrice=menuList[3].menuPrice;
selectedChoice[3].menuChoice=menuList[3].menuChoice;
amtft++;
}
else
amtft++;

price = menuList[3].menuPrice;
amt = amtft;
fttotal = iTotal (price, amt);
break;

case 5:
cout << setw(53)<< menuList[4].menuChoice <<" " << menuList[4].menuPrice<<endl;

if (amtce == 0)
{
selectedChoice[4].menuPrice=menuList[4].menuPrice;
selectedChoice[4].menuChoice=menuList[4].menuChoice;
amtce++;
}
else
amtce++;

price = menuList[4].menuPrice;
amt = amtce;
cetotal = iTotal (price, amt);
break;

case 6:
cout << setw(53)<< menuList[5].menuChoice <<" " << menuList[5].menuPrice<<endl;

if (amtco == 0)
{
selectedChoice[5].menuPrice=menuList[5].menuPrice;
selectedChoice[5].menuChoice=menuList[5].menuChoice;
amtco++;
}
else
amtco++;

price = menuList[5].menuPrice;
amt = amtco;
cototal = iTotal (price, amt);
break;

case 7:
cout << setw(53)<< menuList[6].menuChoice <<" " << menuList[6].menuPrice<<endl;

if (amtt == 0)
{
selectedChoice[6].menuPrice=menuList[6].menuPrice;
selectedChoice[6].menuChoice=menuList[6].menuChoice;
amtt++;
}
else
amtt++;

price = menuList[6].menuPrice;
amt = amtt;
ttotal = iTotal (price, amt);
break;

case 0:
break;

default:
cout << "That choice is not on the menu!!" << endl;
break;
}
}

cout << " Welcome to Johnny's Restaurant "<<endl;
cout << " Your Bill "<<endl;
cout << endl;
cout << setw(20)<<"Menu Item "<<setw(20)<<"Price(USD $)"<<endl;

for(int f=0;f<7;f++) //Extracts data from struct 2 and outputs them on the screen
{
if (selectedChoice[f].menuChoice==" ")
f++;
else
cout<<setw(20)<<selectedMenu[f].menuChoice<<setw(20)<<selectedChoice[f].menuPrice<<endl;
}
cout<<endl;
cout<<setw(20)<<"Taxes"<<setprecision(2)<<setw(35) <<taxamt<<endl;
cout<<endl;
cout<<setw(20)<<"Amount Due"<<setprecision(3)<<setw(35)<<fnltotal<<endl;
cout<<endl;
}



int main()
{

menuItem menuList[7];

getData(menuList);
showMenu(menuList);
printCheck(menuList);






system("Pause");
return 0;
}
Feb 10 '12 #1
1 1456
weaknessforcats
9,208 Expert Mod 8TB
When you use the << operator with a menuChoice variable, the compiler is trying to tell you that it doesn't know how to use the << operator with a string object.

You neeed to convert the string from a C++ string to a C string in order to display it:

Expand|Select|Wrap|Line Numbers
  1. cout << var.menuChoice.c_str();
  2.  
Feb 11 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Francisco J. Reyes | last post by:
I get an Internal complier error when compiling C# windows project that uses a custom Class add as reference to the project. The problem appears to be related to the ENUM type used in the class...
22
by: TuPLaD | last post by:
Hello, I just made a little C++ console application: #include "iostream" using namespace std; int main () { cout << "Hello Mars !"; return 0;
2
by: Marty | last post by:
Hi, 1-I am getting this error and I don't know what does it mean, can anybody help me with the meaning of this? error C2850: 'PCH header file' : only allowed at file scope; may not be in a...
6
by: mihailsmilev | last post by:
Hello, let me first describe the situation: I am developing an application using Qt Designer 3.3.5 on OpenSuSE Linux for my mp3 player. So I need to get the id3 tags from the mp3 files, and I've...
2
by: etienne | last post by:
Hello, I'm trying to compile this C++ code with gcc 3.4.5 under Solaris/SPARC (from a complete application, the file is : FullLinkedList.hh) but the make fails (no problem when compiling under...
6
by: tony | last post by:
Hello! I have several projects where each one build a library.(class library or window control library). Now I get some strange compile error when building the *.exe file and doesn't...
0
by: jmawebco | last post by:
I have a project I'm working on in VS2005 using vb.net with a MSSql 2005 backend. Everytime I try to run the application I get the same error message; ********* ERROR ********* Compilation...
1
by: =?Utf-8?B?UGllcnJl?= | last post by:
Hello, I have an simle application that uses a referenced library of my own. It's been a year now that I have no problems until a few days. Here is the details of my problem: The library...
1
by: AravindS | last post by:
Hi In one of my projects I have to consume an VC8 compiled library from within a VC6 application. When i compile my application in VC6 i get a linker error error LNK2001: unresolved external...
1
kirubagari
by: kirubagari | last post by:
/* Open file and write out header info */ //sprintf(fullPath, "%s/%s", fPath ,fName); fPtr = fopen("./error_file.log", "a+"); if( fPtr == NULL ) { This is my code and im getting error ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.