In this situation,
A.h
#include "B.h"
class A{
private:
static int n;
friend void B::setN(int _n);
};
A.cpp
#include "A.h"
int A::n = 0;
B.h
class B{
public:
static void setN(int _n);
};
B.cpp
#include "B.h"
#include "A.h"
void B::setN(int _n) { A::n = _n; }
IntelliSense: member "A::n" (declared at of "A.h") is inaccessible has occured.
But if I correct friend void B::setN(int _n); to friend class B;, it has no error.
Why can't I use this way?
I hope that only the static member function is accessible.