-
Help please
Here is the code:
Code:
#include<iostream.h>
#include<conio.h>
#include<string.h>
class Order
{
Order yearEndTotal(Order summary, Order oneOrder);
private:
char customerName[20];
int orderQuantity;
public:
Order();
setValues();
displayValues();
};
Order::Order()
{
strcpy(customerName,name);
orderQuantity=0;
};
void setValues()
{
cout<<"Enter customer name ";
cin>>name;
cout<<"Enter quantity ordered: ";
cin>>orderQuantity;
};
void Order::displayValues()
{
cout<<customerName<<" ordered "<<orderQuantity<<"items."<<endl;
};
Order yearEndTotal(Order summary, Order oneOrder)
{
summary.orderQuantity = oneOrder.orderQuantity;
return(summary);
};
void main()
{
const int ORDERS = 10;
Order anOrder[ORDERS];
Order summary;
int x;
for(x=0; x<ORDERS; ++x);
anOrder[x].setValues();
for(x = 0; x< ORDERS; ++x)
{
summary = yearEndTotal(summary,anOrder[x]);
};
summary.displayValues();
getch();
};
All I have to do is debug and I am not able to fix the seven erros that I am getting. Can anyone help?
-
NEVER use void main, its WRONG.
That and you havent declared most of your variables, just used them. Start with the cprog tutorials.
-
I didn't write the program. It was given to me and what I have to do is compile, build and fix any errors. If I can change to int main() I don't know. This is how it was given to me.
-
so its homework, do some reading and stay awake in class.
-
Actually it's not my homework. I have a sister that was in a bad accident and in the hospital, with only four weeks left in class and not wanting to drop I was trying to help her. Someone recommended this site to me, said the people were great and a huge help....I have yet to find that.
-
>>said the people were great and a huge help
We are, but not when someone is trying to weasel out of homework. You need to read the errors, if it says undeclared then you need to declare it before you use it. Example, you have
cin >> name;
but you never declare the variable, ie
string name;
Show some effort, and post updated code if you get stuck.
-
class member func prototypes dont match functions.Specify correct return values. void is never implicit.fix that and if you get more errors post them. hard to fix errors if you dont give us more of a clue. your compiler is your biggest friend. learn to use it.