How to use generic type function template with two parameters in C++

1 Answer

0 votes
#include <iostream>

using std::cout;
using std::endl;

template <class typeA, class typeB>
void function(typeA x, typeB y)
{
	cout << x << ' ' << y << endl;
}

int main()
{
	function(872, "c++");

	function(3.14, 999999L);

	return 0;
}


/*
run:

872 c++
3.14 999999

*/

 



answered Aug 1, 2018 by avibootz
...