1 Replies - 2522 Views - Last Post: 19 March 2009 - 01:55 PM Rate Topic: -----

#1 CorpseOfAZombie   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 20-February 09

How do I return multiple values from a function?

Post icon  Posted 19 March 2009 - 01:38 PM

I'm doing a program that will determine your change and return the maximum amount allowed in $100's, 50's, 20's, 10's, etc. However, if I recall, you can only return a single value from a function with the 'return' keyword. So how can I return the # of each bill/cent I will get back? Should I just use multiple functions or what?
Is This A Good Question/Topic? 0
  • +

Replies To: How do I return multiple values from a function?

#2 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3207
  • View blog
  • Posts: 19,239
  • Joined: 14-September 07

Re: How do I return multiple values from a function?

Posted 19 March 2009 - 01:55 PM

Pass references to the variables you need changed:

int function(int& dollars, int& cents)//etc...
{
 dollars = 5; //original var is changed
  return somethingElse;
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1