l******e 发帖数: 94 | 1 to define A:Func1 as a friend function of class B, can we seperate the
declaration of A and B in different files?
I know the following codes work, but it uses forward declaration and
mandates the declaration of A and B exist in the same source file. Is there
any way to seperate the declaration of A and B into two header files? | l******e 发帖数: 94 | 2 ding yi xia , you ren zhidao da an me?
there
【在 l******e 的大作中提到】 : to define A:Func1 as a friend function of class B, can we seperate the : declaration of A and B in different files? : I know the following codes work, but it uses forward declaration and : mandates the declaration of A and B exist in the same source file. Is there : any way to seperate the declaration of A and B into two header files?
| p****o 发帖数: 1340 | 3 of course, but you still need to include the header of B in the header of A.
does it buy you anything?
there
【在 l******e 的大作中提到】 : to define A:Func1 as a friend function of class B, can we seperate the : declaration of A and B in different files? : I know the following codes work, but it uses forward declaration and : mandates the declaration of A and B exist in the same source file. Is there : any way to seperate the declaration of A and B into two header files?
| l******e 发帖数: 94 | 4 header of B has A::Func1( ..) as the friend function, so when B is compiled,
the compiler cannot recognized A if they're in two files, I got compiler
error.
A.
【在 p****o 的大作中提到】 : of course, but you still need to include the header of B in the header of A. : does it buy you anything? : : there
| d******e 发帖数: 194 | 5 try adding keyword 'class' before A. as such:
friend int class A::Func1(..)
compiled,
【在 l******e 的大作中提到】 : header of B has A::Func1( ..) as the friend function, so when B is compiled, : the compiler cannot recognized A if they're in two files, I got compiler : error. : : A.
|
|