What are templates? Do they have advantages over polymorphism?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aniamiavi
    New Member
    • Aug 2012
    • 1

    What are templates? Do they have advantages over polymorphism?

    what are templates?Do templates have more adavatages over polymorphism?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Templates and polymrpism are two different things. There is no connection between them.

    A template is used when you have the same code used for many types. You replace the type with a parameter. Then when you compile your code, the compiler makes a copy of the template and substitutes the actual type fr the parameter.

    Many examples on the web about this.

    Comment

    Working...