Hey Im getting an error I think has to do with copying ofstream variable from reading other posts and Ive tried to change
std::ofstream outfil;
You are declaring outfil as a reference to an object of type std::ofstream with the following line in main:
outfil
std::ofstream
std::ofstream & outfil;
References must be initialized upon declaration. Your solution is to declare outfil as: