Usually that is done using just a really long list of possible strings for first anmes, and for last names, and randomly selecting and combining them. You could even use an external text file for this purpose.
You could, I suppose, come up with an algo to generate a random name based on a set of phonetic elements, but a list is more reliable and usually simpler.
Perhaps something like:
Code:
pseudo...
class nameengine {
public:
nameengine(char* fileName) {open filename, read the integer, .getline that many times and put in firstnames vector, then repeat for last names}
first() {return random element from firstNames}
last() {return random element from lsstNames}
full {return first()+' '+last()}
private:
vector<string> firstNames;
vector<string> lastNames;
};
Then in your game just instantiate a few engines like:
Code:
nameengine ElvenNames("elfnames.txt");
nameengine HumanNames("mannames.txt");
string thisElfsName = ElvenNames.full();