just simple question where that values come :P
i write calculator for int and double on template... i was think its get any off variabels and i try add char and int ( not only add :P ) and my question its how its calculate. Code : #include <iostream> using namespace std; template <class Cal1 , class Cal2> Cal1 sum(Cal1 a, Cal2 b) { return a+b; } template <class Cal1 , class Cal2> Cal1 sub(Cal1 a, Cal2 b){ return a-b; } template <class Cal1 , class Cal2> Cal1 sub1(Cal1 a, Cal2 b){ return b-a; } template <class Cal1 , class Cal2> Cal1 mul(Cal1 a, Cal2 b){ return a*b; } template <class Cal1 , class Cal2> Cal1 divi(Cal1 a, Cal2 b){ if ( b != 0){ return a/b; } else { cout << "Error division by "; } return 0; } template <class Cal1 , class Cal2> Cal1 divi1(Cal1 a, Cal2 b){ if ( b != 0){ return b/a; } else { cout << "Error division by "; } return 0; } int main() { char x='1'; int y=2.0; if (sizeof(x)>=8){ cout << "calculating for double:" << endl; cout << sum(x,y) << endl << sub(x,y) << endl; cout << mul(x,y) << endl; cout << divi(x,y)<< endl;} else{ cout << "calculating for double:" << endl; cout << sum(y,x) << endl << sub1(y,x) << endl; cout << mul(y,x) << endl; cout << divi1(y,x)<< endl;} return 0; } and output: calculating for double: 51 47 98 24