Q:

Why can templates only be implemented in the header file in c++?

0

Why can templates only be implemented in the header file in c++?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Answer:

It is not necessary to implement or define a template in the header file but we can define in .cpp. But if you are defining the methods in .cpp file then you have to include .cpp file in template header file either you need to define the template type explicitly in .cpp file. Let me know if you want a detailed article on this topic.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now