well the problem was:
2. Rewrite Listing 4.4, using the C++ string class instead of char arrays.
Listing 4.4
// instr2.cpp -- reading more than one word with getline
#include <iostream>
int main()
{
using namespace std;
const int ArSize = 20;
char name[ArSize];
char dessert[ArSize];
cout << “Enter your name:\n”;
cin.getline(name, ArSize); // reads through newline
cout << “Enter your favorite dessert:\n”;
cin.getline(dessert, ArSize);
cout << “I have some delicious “ << dessert;
cout << “ for you, “ << name << “.\n”;
return 0;
}
so solving this would be:
#include <string>
#include <iostream>
int main()
{
using namespace std;
string name,dessert;
cout << "Enter your name:\n";
cin >> name;
cout << "Enter your favorite dessert:\n";
cin >> dessert;
cout << "I have some delicious " << dessert;
cout << " for you, " << name << ".\n";
system("pause");
return 0;
}
finally I learn what is a string I think that using string is better than using any types of variables right? cause why would be it created?