Function Templates in C++

#include <iostream>
using namespace std;
template <typename T>
void ourFunction(T p)
{
    cout << "Value is : " << p << endl;
}

int main()
{

    ourFunction<int>(45);
    ourFunction<double>(79.40);
    ourFunction<char>('H');

    return 0;
}

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *