// How to pass default arguments to function templates. ?
#include <iostream>
using namespace std;
// template<typename A=int,typename B>
//Code Produces error if above line is uncommented
template<typename A,typename B>
void function(A,B);
int main()
{
function(5,3.2);
return 0;
}
template<typename A,typename B>
void function(A a,B b)
{
cout <<"Sum: " << a+b << endl;
}
Last edited on
Hi Framework,
Thanks for answering this question.
This is the compiler which I use.
gcc version 4.4.3
Best,
Vikram
I can't seem to find the manual for your compiler. Sorry. However, you could try what I previously posted and see if that fixes your problem.
Wazzak
Thanks, your fix works for me.