X
xdli888
I have two classes , say A and B. A contains methods named f1() ,
f2() and B contains methods named g1(), g2().
f1() will invoke g2() and g1() will invoke f2(). This situation is
kinda like two things interact with each other.
But the program couldn't pass the compliation. g++ says " invalid use
of undefined type of ......" .
As far as I know, forward declaration couldn't solve this problem, and
I have tried. Both of the definition of the two classes has to come
first which is not possible.
This can be solved by redesign A and B, but I wish I can find some
other solutions here, any advice will be welcome .
f2() and B contains methods named g1(), g2().
f1() will invoke g2() and g1() will invoke f2(). This situation is
kinda like two things interact with each other.
But the program couldn't pass the compliation. g++ says " invalid use
of undefined type of ......" .
As far as I know, forward declaration couldn't solve this problem, and
I have tried. Both of the definition of the two classes has to come
first which is not possible.
This can be solved by redesign A and B, but I wish I can find some
other solutions here, any advice will be welcome .