I tried to use an include on just one of the files but it would go into the class e.g. class a and the fail to compile because class b had not been declared. I also put the include in both files that seemed to put the compiler in an infinite loop. Any ideas?
I think that this feature of templates - lets call it 'late binding' - should be incorporated into
the standard C++ compilation process (or would that just make more work for hard pressed C++
compiler writers).
// a.h - give it a header guard
class B;
class A
{
int doSomething(B bIn);
};
#include "b.h"
inlineint A::doSomething(B bIn) // or instead of making it inline, put it in a cpp
{
return bIn.getNum();
}