+ è un operando di concatenazione:
PS. Potresti scrivere direttamente ofstream fout((titolo + ".txt").c_str());codice:#include <fstream> #include <iostream> #include <string> using namespace std; int main() { string titolo; string testo; string f; cout << "Inserisci il titolo: "; getline(cin, titolo); cout << "Inserisci il testo:" << endl; getline(cin, testo); f = titolo + ".txt"; // Concatenazione ofstream fout(f.c_str()); // il costruttore richiede un const char * fout << titolo << endl; fout << testo; fout.close(); system("PAUSE"); return 0; }