variable ‘std:ofstream’ has initializer but incomplete type

The reason is that the header file fstream was not added.

Add the

#include<fstream> 

Read More: