hiding non template dependent implementation in a template class

E

er

hi,

suppose i have
a)
template<typename T>
class B{
A*
public:
/* depends on T*/
};

or

b)
class B{
A*
public:
template<typename T>
double f(T&); /* impl depends on T */
};

-if the template was not there i would only need to declare A in the
header of B and #include "A.h" in its source file.
- with the inclusion model (declaration & definitions included in a
common hpp) for templates, i obviously cannot do this.
- for b) i did not run into problem with a toy problem (as above) by
keeping the definitions of B::f(T&) in the header, and every other
definition in the cpp file.
-but for a more complex class, for b) i did run into problem "invalid
use of undefined struct `A"class.

before i start looking into the explicit and separation models (i
remember running into problems with export with g++) -if at all useful
in this case- could someone please offer a little of guidance on this
issue?
 
E

er

hi,

suppose i have
a)
template<typename T>
class B{
A*
public:
/* depends on T*/

};

or

b)
class B{
A*
public:
template<typename T>
double f(T&); /* impl depends on T */

};

-if the template was not there i would only need to declare A in the
header of B and #include "A.h" in its source file.
- with the inclusion model (declaration & definitions included in a
common hpp) for templates, i obviously cannot do this.
- for b) i did not run into problem with a toy problem (as above) by
keeping the definitions of B::f(T&) in the header, and every other
definition in the cpp file.
-but for a more complex class, for b) i did run into problem "invalid
use of undefined struct `A"class.

before i start looking into the explicit and separation models (i
remember running into problems with export with g++) -if at all useful
in this case- could someone please offer a little of guidance on this
issue?

ps: i guess i could replace A* by

class A_wrap{
A*;
};

?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top