Function uses two arguments
#include <iostream>
#include <string>
using namespace std;
void printMessage(string, string);
int main ()
{
string name1, name2;
cout << "Enter first name: ";
cin >> name1;
cout << "Enter last name: ";
cin >> name2;
printMessage(name1, name2);
return 0;
}
void printMessage (string firstName, string lastName)
{
cout << "Your name is " << firstName << " " << lastName << endl;
}
Related examples in the same category