Functions

I'm trying to to make a program that displays other functions that displays other functions. To do that I have to get a function to return strings and ints at the same time. How do I do that? If there is a way....
Something kinda like this.....
int function(int, string);
you can't get a function to return more than 1 thing.
You can have a function that takes the address of a variable though, and this will allow for changing that variables data, rather than just changing a copy of the variable.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int function(int i, string& str)
{
   // this makes a copy of i
   // this IS the address of string

   // manipulate both
   i++;
   getline(cin,str);
   return i;
}

int main()
{
   int x =9;
   string str="Hello"
   x = function(x, str);

   return 0;
}


enter: World.

x = 10;
str = "World."
Ok thanks! :)
Topic archived. No new replies allowed.