void student::writeLongRecord_2() //add another student data
{
int i;
float mark;
int long number;
string array[4];
int y;
string line;
ofstream aFile;
ifstream x("student.txt");
Are you referring to the ifstream instance of x? If so, I'm not. I'm referring to ofstream instance of aFile. The constructor doesn't open the file by default in either instance. However, if the file's name is given as a constructor argument, the file is opened.
Read this before telling people they're wrong: http://www.cplusplus.com/reference/iostream/ofstream/ofstream/