Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Templates and headers

Tags:

c++

templates

So do any of the future standards of c++ plan to resolve the issue of having to combine the declaration and implementation?

like image 909
poy Avatar asked May 09 '26 14:05

poy


1 Answers

There's a very good reason why the template implementation needs to go into the header. A template is not code - it's only a template for the automatic generation of code. The code doesn't get created until you try to use it with the template parameters filled in. The compiler needs to have the full template body in order to fill in the blanks and get working code.

like image 163
Mark Ransom Avatar answered May 11 '26 03:05

Mark Ransom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!