passing structures into functions

Hi I've been messing around trying to pass structures into functions.
my structure looks like this
struct menutype{
int id;
char name[26];
float price;
float multi;
float quanity;
float number;

};
This is what i want in a function
for(int row=0; row<5; row++){menu[row].number=0;
menu[row].number=menu[row].price*menu[row].quanity;
cout<<fixed<<showpoint<<setprecision(2);
cout<<left<<setw(5)<<menu[row].id
<<left<<setw(25)<<menu[row].name
<<left<<setw(10)<<menu[row].price
<<left<<setw(5)<<menu[row].multi
<<left<<setw(10)<<menu[row].quanity
<<left<<setw(10)<<menu[row].number<<endl;}
any suggestions?
You pass your custom types into functions much like you pass normal types i.e make a copy or a reference or a pointer to the type.
using your type:
1
2
3
4
5
6
void setMenu(menutype& mt) { ... } // pass by reference
void displayMenu(menutype mt) { ... } // pass by copy 

menutype mtObject;
setMenu(mtObject);
displayMenu(mtObject);

Topic archived. No new replies allowed.