C++ variable scope for class friends -
i have:
class game... class d3dgraphics...
i have variable of type d3dgraphics called gfx declared in game class.
i make few classes:
class font... class viewport...
i make them both friends of d3dgraphics , declare variables inside d3dgraphics class:
font font; viewport viewport;
finally in d3dgraphics have variable made public:
lpdirect3ddevice9 d3ddevice;
my font class cannot see d3ddevice though friend of d3dgraphics?
why that?
edit::// have changed code around push pointers through outside classes: https://github.com/jimmyt1988/thegame/tree/master/thegame
- windows.cpp // create game object , pass hwnd through.
- game.cpp / game.h
- font.cpp / font.h
- d3dgraphics.cpp / d3dgraphics.h
- viewport.cpp / viewport.h
at least if understand correctly, you're expecting friendship transitive -- i.e., friend of b , b friend of c, you're expecting a friend of c.
if so, simple answer because (as c++ defines it) friendship not transitive.
Comments
Post a Comment