dunque il codice completo purteroppo non lo posso postare,

nell header:

#include <string>
#include <sstream>
#include <iostream>
#include <fstream>

e nella classe

static string file;
static stringstream fn;


nel .cc:

all esterno:

string NomeClasse::file;
stringstream NomeClasse::fn;

nella funzione:

fn.str("");
fn << 2;
file = "transizioni" + fn.str() + ".txt";