Here is some C++ example code that compiles and works fine:
class A
{
public:
A() {/* empty */}
private:
friend void IncrementValue(A &);
int v
Sure. Read the second line of the error message carefully: the function was declared extern
and later static
. So all you have to do is declare it static before the friend declaration:
class A;
static void IncrementValue(A&);
class A {
// class definition, including friend declaration
};
static void IncrementValue(A&) {
// code here, of course
}