You have two problems:
>int stack::compare
compare is a friend, not a member. You don't qualify friends as if they were members unless they actually are.
>friend int compare( const stack &stack1, const stack &stack2 );
>int compare( const stack stack1, const stack stack2 )
Notice how the declaration takes references to a const stack and the definition takes const stack objects. These are two different functions and the compiler will treat them as overloads. Change the definition to match the declaration and the code will compile:
class stack {
private:
int count;
int data[SIZE];
public:
void init( void );
void push( const int item );
int pop( void );
friend int compare( const stack &stack1, const stack &stack2 );
};
...
int compare( const stack &stack1, const stack &stack2 )
{
if( stack1.count != stack2.count )
return(0);
for( int i = 0; i < stack1.count; ++i )
{
if( stack1.data[i] != stack2.data[i] )
return(0);
};
return(1);
};