Archived

This topic is now archived and is closed to further replies.

returning variables

This topic is 6008 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Guest Anonymous Poster
you cant return 2 variables, but you can pass the address of 2 variables and change them in the function

ex.
void func(int *v1, int *v2)
{
*v1 = 1;
*v2 = 2;
}

to call
int var1, var2;
func(&var1, &var2);

now var1 will = 1, and var2 will = 2

Share this post


Link to post
Share on other sites
Similarly to the previous post:

void func(int &v1, int &v2)
{
v1 = 1;
v2 = 2;
}

and to call it:

int var1, var2;

func(var1, var2);

var1 will equal 1 and var2 will be 2.

Edited by - Akhenaten on June 29, 2001 10:41:43 AM

Share this post


Link to post
Share on other sites