I've got a following code written in C++:
#include <iostream>
using namespace std;
class Window;
class Level
{
int level;
int get(Window& w);
public:
Level(void): level(3) {}
void show(Window& w);
};
void Level::show(Window& w)
{
cout << get(w) << endl;
}
class Item
{
static const int item = 8;
};
class Window
{
friend int Level::get(Window& w);
int window;
public:
Window(void): window(2) {}
void show(void);
};
void Window::show(void)
{
cout << "window" << endl;
}
int Level::get(Window& w)
{
return w.window + level;
}
int main()
{
Window wnd;
Level lvl;
wnd.show();
lvl.show(wnd);
cin.get();
return 0;
}
I want to have access to private member of class Window only accessible by friend function get, which is also private function of class Level. When I'm trying to compile I've got an error C2248. Is that possible to make private function as friend of other class?