-1

I used the following to write my template inside a cpp instead of the header file because i prefer to keep the code clean.

Storing C++ template function definitions in a .CPP file

In .hpp
template <class obj_class> void plotLaser(int zoom, void * obj);

In .cpp
class visualizer {...};
class annotator : public visualizer {...};
template void plotLaser<visualizer>(int zoom, void * obj) {...};

Can I use the template to call plotLaser<annotator>(...); or do I have to rewrite it?

Community
  • 1
  • 1
sfotiadis
  • 959
  • 10
  • 24
  • No I'm in the process of splitting my class right now to be honest, I can't afford to mess things more. I will try it later though, probably with dummy classes. – sfotiadis Dec 14 '12 at 17:29

1 Answers1

0

you need to re-write it I think. Because your code

    template void plotLaser<visualizer>(int zoom, void * obj) {...};

is a specialization.

if you need one for annotator, you need to one specialization for it.

CS Pei
  • 10,869
  • 1
  • 27
  • 46