Difference between using Inheritance and Templates

This is a discussion on Difference between using Inheritance and Templates within the C++ Programming forums, part of the General Programming Boards category; Hi I have read about inheritance and templates. What I have understood is that,both of them provide reusabilty of code, ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    104

    Difference between using Inheritance and Templates

    Hi

    I have read about inheritance and templates. What I have understood is that,both of them provide reusabilty of code, then what is the basic difference between them and which one should be used in what conditions?

    Please help with example
    Thanks

  2. #2
    Noob AnishaKaul's Avatar
    Join Date
    Jan 2010
    Location
    Gurgaon, India
    Posts
    115
    IMO

    Through inheritance you can reuse the *features* of a particular entity.
    and
    Through templates you can reuse the *functions* defined for interaction with that entity.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. templates and inheritance
    By ichijoji in forum C++ Programming
    Replies: 2
    Last Post: 10-11-2004, 04:34 PM
  2. Dilemma with templates and inheritance..!
    By Halloko in forum C++ Programming
    Replies: 3
    Last Post: 07-21-2004, 02:01 PM
  3. templates and inheritance problem
    By kuhnmi in forum C++ Programming
    Replies: 4
    Last Post: 06-14-2004, 03:46 AM
  4. Problem with overloaded operators, templates and inheritance
    By bleakcabal in forum C++ Programming
    Replies: 1
    Last Post: 03-19-2004, 05:07 AM
  5. Mixing templates and inheritance, and the damage caused ;)
    By SilentStrike in forum C++ Programming
    Replies: 2
    Last Post: 09-19-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21