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)

C++ Interview Questions For Experienced

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Do all virtual functions need to be implemented in... >>
<< Why is “using namespace std;” considered bad p...