C++ help please

how do i write a function that returns a function that accepts one argument as the change. The function should convert the change in numbers of dollar, quarter, dime, nickel and penny.

for example: if someone pays $5.00 for a total $3.14 purchase, the program should have 1 dollar, 3 quarters, 1 dime and 1 cent as the result.
If I understand your question correctly, you could possibly make a class or structure like so:

1
2
3
struct Change {
   int dollars, quarters, dimes, cents;
}

Then you can just have the function return something of that type.

1
2
3
4
5
6
7
Change DetermineChange( /* ... */ ) {
   // determine change, etc
   Change ret;
   ret.dollars = dollar_change;
   //etc
   return ret;
}
Topic archived. No new replies allowed.