PDA

Click to See Complete Forum and Search --> : Structure & Functions Problem


Jacob
Jan 27th, 2002, 04:38 PM
Hi.

I'm doing an assignment which uses structure to store a series of product name and each name has its own quantity. The program then use a function to let the user to enter the product he/she wants and add the quantity. The main problem is that I don't know how to pass my structure into my Add_Quantity function. Would you tell me how to do it?

Thank You

Jacob

kedaman
Jan 27th, 2002, 07:24 PM
you pass anything to a function the same way as any integral type. If your function should store into the struct or is otherways quite large, you should declare it to take a reference.
by reference

returntype function(&yourstruct localname){
}

by value

returntype function(yourstruct localname){
}

in both cases you call function(thestruct);

HarryW
Jan 27th, 2002, 09:19 PM
Originally posted by kedaman

returntype function(&yourstruct localname){
}
I think this is supposed to be:

returntype function(yourstruct& localname){
}