I messed up

So in short, I wrote this large overcomplicated function (if you want i can post it) which produces three strings: rand_female_name, rand_male_name, rand_evil_name. To test it, I wrote it as a separate document in the main function. Everything worked as intended but then to my horror I realized that I can,t make a function out of this code.... I mean I can, but I can't get it to return 3 separate values which can then be assigned to variables in my code. The first obvious solution that came to me was to write 3 separate functions that would each return a separate string, but I came here hoping there was an easier way. Thanks in advance.
hope i understood that right, you want your function to return 3 strings.
that's not possible, a function can't return several variables.
but you can return an array/vector/... of strings or simply call the function with string-parameters as reference.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct names
{
    string rand_female_name;
    string rand_male_name;
    string rand_evil_name;
};

names foo()
{
    names temp;
    temp.rand_female_name = "Mary";
    temp.rand_male_name = "Max";
    temp.rand_evil_name = "Morgoth";

    return temp;
}

Thank you for your help I tried passing an array as a parameter before but as it turns out my syntax was just wrong.
Topic archived. No new replies allowed.