anonymous
  • anonymous
help with passing vector array to a function (c++)?
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
i need to do this: For each employee, compute and print the employee's base pay, which includes overtime (paid at one and a half times the normal rate) for each hour over 40. For example, if an employee earning $20.00 per hour works for 48 hours, then she will be paid for 40 hours at her normal rate plus 8 extra hours at $30.00 (one and a half times $20.00). check the attachments below for code and input file.
rsmith6559
  • rsmith6559
You can pass a vector to a function by reference: void function( vector & passedIn )
anonymous
  • anonymous
ok thank you that's a start

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
so inside the function first of all how would i compute the base pay? (this is only one small part of the assignment btw i'm not freeloading here just trying to get a grasp on the whole thing.) can i use the same names for them as in main()? e.g., int bp = employee.rate * employee.hours; -- would that work verbatim? also i need to store the base pay for each individual employee in their respective records in the array, i'm pretty sure; how do i do that??? in the function being passed the vector array all i do is code as if it's only a single record that i'm dealing with/in question, right? and then that will apply to each record in the vector?
rsmith6559
  • rsmith6559
Functions have their own namespace. In other words, you can call variables any (legal) thing that you want. int bp = employee.rate * employee.hours; // wouldn't work double bp = employee.rate * employee.hours; // would work The employee objects are completely separate entities. Your vector (arrays are a different thing, not as easy to use as vectors) would probably be holding employee objects. Each employee would have their own base pay, if that's part of the employee object. You may want to code it so that the function that calculates pay just deals with one employee object, and another function takes care of iterating through the vector, passing each employee to the calculating function in turn. The calculating function could also be part of the employee object, a member function (method) that the iterating function just calls on each employee object. The down side to versatile languages is that there can be too many ways to do something.

Looking for something else?

Not the answer you are looking for? Search for more explanations.