1. You declare it to be a friend only in the class body.
you define it elsewhere without the friend directive because outside the class it would mean it's a friend to the global scope, which wouldn't be much use
friend ostream& operator<<(ostream& out, const kom&);
}; //<===Don't forget the semicolon after the class declaration
now you can use it as such
//defined outside the scope of kom
ostream& operator<<(ostream& out, const kom&)
//don't use cout, cout is the standard output, you want
//to use any output stream such as a file or string stream or any
//other stream object
return out; //remember to return it.
//do whatever it is you want with your class
cout << aKom;
outfile << aKom;
outsstream << aKom;