Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 2

Generic Function and Class

 Problem with simple class is that data types is fixed.


 So same operations on different data types with same
class can not be performed.
 For example if we have class which add two integer
number then same class can not work with addition of
float no.
 This can be done using generalize class.
 Template is used for that.
 Example
Generic Function and Class

 Definition of Template
template
<template_param_declaration>
class Classname
{
Statement

You might also like