I am having trouble with concatenation in C++ with Visual Studio. I have tried different variations of the cout but to no avail.
#include "std_lib_facilities.h"
int main()
{
cout << "Please enter last name and age\n";
string first_name;
string last_name;
string l2 = "Mr. " + last_name;
int age;
cin >> last_name >> age;
cout << "Hello, " << l2 << age << "\n";
}
Can anyone help explain what is going on here that prevents it from displaying "Hello, Mr. last_name age"? The current output just displays "Hello, Mr. 22".
Aucun commentaire:
Enregistrer un commentaire