954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

friend function not compiling

Hi All,

I'm having a problem with a friend function I am using. The darn thing just won't compile!

It goes something like this

class G 
{
protected:
  public:
     void reduce(H& Cost);
};
void G::reduce(H& Cost)
{
     Cost = Cost * 0.95;
}


and later

Class H
protected: 

friend void reduce(H& Price);

float Price;

I get a few errors;
expected ; before ( token
void G::reduce(HardwareDevice& Cost) is not a static member of class G
H not declared in this scope
reduce not declared in this scope

Any ideas appreciated.

Thanks

spacecowboy123
Newbie Poster
14 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

since you did not post the exact code I dobt anyone can help you. I hope that is not really the way you declared class H. :eek:

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You