The friend function needs to know that classes c1
and c2
exist. c1
is fine, because the friend is declared with in that class. But for c2
you need a forward declaration before the first friend
declaration:
#include<iostream>
using std::cin;
using std::cout;
class c2; // forward declaration
class c1{
....
friend void output(c1 obj1, c2 obj2); // OK now
};
I also added some missing declarations. You also need the headers for getch
and clrscr
.