Thread: Difference between using Inheritance and Templates

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

    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, 03:34 PM
  2. Dilemma with templates and inheritance..!
    By Halloko in forum C++ Programming
    Replies: 3
    Last Post: 07-21-2004, 01:01 PM
  3. templates and inheritance problem
    By kuhnmi in forum C++ Programming
    Replies: 4
    Last Post: 06-14-2004, 02: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-18-2001, 11:47 PM