declaring class member functions as friend without full class definition : c++
This is a discussion on declaring class member functions as friend without full class definition within the c++ forums in Programming Languages category; Hello, I am attempting to change a existing large code base and I have this situation: A.hpp class A { .... friend void B::member_function1() const; ... }; When I include B.hpp for the definition of B, I seem to fall in cross-include situation where the include guards don't work (or work bad...) I tried forward declaring class B before A, but it seems the full definition of B is required to declare its member function as a friend to A. Is there a solution to this? regards,...
| c++ comp.lang.c++ usenet archive |
![]() |
| | LinkBack | Thread Tools |
|
#1
| |||
| |||
| I am attempting to change a existing large code base and I have this situation: A.hpp class A { .... friend void B::member_function1() const; ... }; When I include B.hpp for the definition of B, I seem to fall in cross-include situation where the include guards don't work (or work bad...) I tried forward declaring class B before A, but it seems the full definition of B is required to declare its member function as a friend to A. Is there a solution to this? regards, |
|
#2
| |||
| |||
| On 2008-11-11 16:19:07 -0500, "Hicham Mouline" <hicham@mouline.org> said: > Hello, > > I am attempting to change a existing large code base and I have this > situation: > > A.hpp > class A { > .... > friend void B::member_function1() const; > ... > }; > > > When I include B.hpp for the definition of B, I seem to fall in > cross-include situation where the include guards > don't work (or work bad...) > > I tried forward declaring class B before A, but it seems the full definition > of B is required > to declare its member function as a friend to A. > > Is there a solution to this? > Sure. Put the full definition of B before the definition of A. Since you haven't shown any other code, it's impossible to guess the causes of whatever other problems you've been running into. -- Pete Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The Standard C++ Library Extensions: a Tutorial and Reference (www.petebecker.com/tr1book) |



