1 / 4

Generic Programming with Templates:

Generic Programming with Templates:. A significant benefit of object oriented programming is reusability of code which eliminates redundant coding An important feature of C++ called templates strengths this benefit of OOP and provides great flexibility to the language

Télécharger la présentation

Generic Programming with Templates:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Generic Programming with Templates: A significant benefit of object oriented programming is reusability of code which eliminates redundant coding An important feature of C++ called templates strengths this benefit of OOP and provides great flexibility to the language Templates support generic programming, which allows to develop reusable software components such as functions, classes, etc.., supporting different data types in a single framework. For instance, functions such as sort, search, swap etc.., which support various data types can be developed.

  2. A template in C++ allows the construction of a family of template functions (function templates) and classes (class templates) to perform the same operation on different data types. • They perform appropriate operations depending on the data type of parameters passed to them. • It allows a single template to deal with a generic data type T.

  3. Function Templates: • There are several functions of considerable importance which have to be used frequently with different data types. The limitations of such functions is that they operate only a particular data type. It can be overcome by defining that function template or generic function. A function template specifies how an individual functions can be constructed.

  4. Disadvantage:

More Related