Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to overload function template in C++

1 Answer

0 votes
#include <iostream>

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

template <class T> void function(T a)
{
	cout << "function(T a): " << a << endl;
}

template <class X, class Y> void function(X a, Y b)
{
	cout << "function(X a, Y b): " << a << " " << b << endl;
}

int main()
{
	function(7);
	function(12, 99);

	return 0;
}


/*
run:

function(T a): 7
function(X a, Y b): 12 99

*/

 



answered Aug 1, 2018 by avibootz

Related questions

1 answer 163 views
1 answer 177 views
2 answers 122 views
2 answers 162 views
162 views asked Dec 10, 2020 by avibootz
3 answers 212 views
1 answer 162 views
...