I have a template class declared in a header file.
// Matrix.htemplate <class X> class Matrix {};
In another header file I have a function declaration which has an instantiation of that template class as return type:
// OtherModule.hMatrix<double> do_stuff();
In the source file of the other module I include the header of the Matrix class:
// OtherModule.cpp#include "Matrix.h"Matrix<double> do_stuff() { // do stuff}
How do I make the compiler know what Matrix<double>
is in the OtherModule header file without including Matrix.h in the header itself?
I tried forward declaration as shown here:
// OtherModule.htemplate class Matrix<double>Matrix<double> do_stuff();
but it doesn't work.