you will need to include either fstream.h (or fstream depending on your compiler) in order to use an ofstream (which is usually what fout is) in your program.
The first error says the compiler can't use fout because it hasn't been declared as a valid object.
The second error says you haven't successfully overloaded the << operator for the class you are using. It may "magically" go away if you correct the first problem.
disclaimer: code untested.
const int MAX = 10;
//overload the << operator for the class sample using friend
friend ostream & ostream<<(ostream & os, sample & s);
//definition of overloaded << operator for class sample
ostream & ostream<< (ostream & os, sample & s)
os << s.data << endl << s.name << endl;
sample1.data = 1;
fout << sample1;