incredi_badd 0 Newbie Poster

Hello,
This assignment is demanding for me. The user is prompted to enter 4 names, and by way of one cout line, call the function 3 times to determine which name comes first lexicographically. Not sorting all 4 names, just displaying which one comes first. Cannot use a loop, or a counter, just one cout statement which calls the function 3 times.

I am pretty sure this is done with the byref & tool but am getting very confused.

heres what I got.

#include <iostream>
#include <string>
using namespace std;



string before (string & name1, string & name2)
{
	if (name1 < name2)
		return name1;
	else 
		return name2;
}



int main()
{
	string name1, name2, name3, name4;

	cout << "Please enter name 1: ";
	getline(cin, name1);
	cout << "Please enter name 2: ";
	getline(cin, name2);
	cout << "Please enter name 3: ";
	getline(cin, name3);
	cout << "Please enter name 4: ";
	getline(cin, name4);

	cout << before(name3, name4), before(name1, name2);
}