62.4k views
2 votes
Why does the use of templates hurt code hiding

A) Templates expose implementation details
B) Templates require explicit instantiation
C) Templates increase code size
D) Templates are not compatible with hiding

User Econ
by
9.0k points

1 Answer

2 votes

Final answer:

The use of templates can hurt code hiding due to the exposure of implementation details, the requirement for explicit instantiations, and the increase in code size.

Step-by-step explanation:

The use of templates can hurt code hiding for several reasons:

  1. Templates expose implementation details because they allow for the definition of generic data types and functions, which can reveal how the code is implemented.
  2. Templates require explicit instantiation to generate code for specific template arguments, which can lead to longer compilation times and bloated object code.
  3. Templates can increase code size because each instantiation of a template generates its own code, potentially leading to code duplication.

Therefore, options A, B, and C are correct.

User Akkatracker
by
7.9k points