That would be simple if you assign the names to an indexed container, like for instance a
std::array<string,3>
or a
std::vector<string>
. Then you just need to pick randomly two different indexes.
[update]
Quote:
I dont know what you mean. I'm so sorry I'm new to c++ and the vector or std is a new to me.
Then, it's time to learn. Try, for instance:
#include <iostream>
#include <array>
using namespace std;
int main()
{
array<string,3> a{"foo", "boo", "goo"}; cout << a[1] << "\n"; }
picking randomly an integer, say
i
, in the
[0..2]
range, your random picked string would be
a[i]
.
[/update]