Sabtu, 24 Desember 2016

How to overload function templates in C++ programming

As normal functions can be overloaded, template functions can also be overloaded. They will have the same name but different number of or type of parameters. Consider the following example which demonstrates template function overloading: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 #include <iostream> using namespace std; void summ(int x, int y) { cout<<“Normal Function: “<<endl; cout<<“Sum is: “<<x+y<<endl; } template<class Type1, class Type2> void summ(Type1 x, Type2 y) { cout<<“Template Function: “<<endl; cout<<“Sum is: “<<x+y<<endl; } int main()

The post How to overload function templates in C++ programming appeared first on Coding Security.


How to overload function templates in C++ programming
read more

Tidak ada komentar:

Posting Komentar