I have made this code to add numbers by adding first argument if you ask why i make it like
that because i will use it to solve a problem in my assignment the code works fine if the numbers are from the same data type for example int and int but if it is from different data types like double and int it no longer works as if static key word on m is not exist
#include<iostream>
using namespace std;
template <class first, class seconde>
void total (first a, seconde b){
static first m =0 ;
static seconde f=0;
++f;
if(b==m){
m+=a;
cout<<m<<endl;
}
m+=a;
}
void main(){
total(2,2);
total(1,2);
system("pause");
}
i need to know it dose not work with different data types when using int and double while iam using template