Thursday, April 19, 2018

c++ - separating constructor implementation with template from header file











My header file has



template 
class AA : public BB
{

public:
AA()
{ ... }


this is working fine. But I need to separate the constructor implementation from header file.



So in cpp, I have



template 

AA::AA()
{ ... }


When I compile this, it compiled but I get unresolved external symbol error. What am I missing here?


Answer



You can explicitly instantiate templates in your implementation file using :



template class AA;



this will generate a definition from a template, but it is of use only if you know what types your class clients will use


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...