The third and final version of the name_box program solves the same problem as the previous two: drawing a box around a user's name. Furthermore, the third version is structurally identical to name_box1.cpp. So similar are the two versions that the accompanying video begins with the first version and changes the variable name from a C-string to an instance of the C++ string class. The changes are few and straightforward:
#include <iostream>
#include <string> // (a)
using namespace std;
int main()
{
string name; // (b)
cout << "Please enter your name: ";
getline(cin, name); // (c)
cout << "+";
for (size_t i = 0; i < name.length(); i++) // (d)
cout << "-";
cout << "+" << endl;
cout << "|" << name << "|\n"; // (e)
cout << "+";
for (size_t i = 0; i < name.length(); i++) // (d)
cout << "-";
cout << "+" << endl;
return 0;
}