Hi all,

I would like to know in what situation template is used instead of inheritance and vice visa. examples are appreciated.

I just know template is static binding while inheritance is dynamic binding. so if speed is concern, template is better.

Recommended Answers

All 3 Replies

template and inerentence at two completly different animals. You would use one instead of the other at any time. I'm not great on templates but I think templates can experience inherentence just as normal classes can.

as they are replaced by each other, I want to know if there is a rule for using template or inheritance in some situation.

>I want to know if there is a rule for using template or inheritance in some situation.
Inheritance applies to behavior, templates apply to data. It's not a one or the other deal; you can use templates to supplement inheritance and vice versa.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.