Bloomberg LP Interview Question
Software Engineer / DevelopersCompiled and run the following:
1 #include <stdio.h>
2
3 template<class T1, class T2, class T3>
4 int Pr(T1 a,T2 b,T3 c)
5 {
6 printf("a: %f b: %f c:%f\n",a,b,c);
7 return a*b*c;
8 }
9
10 int main()
11 {
12 int x = Pr(1.1,2.1,3.1);
13 printf("%d\n",x);
14 return 0;
15 }
Output:
a: 1.100000 b: 2.100000 c:3.100000
7
So I see, either there is typo with ";" or there is syntactically nothing wrong. I am not sure whether the question involves semantic error of any kind.
template<class T1;class T2;class T3> is a syntax error
- jav January 19, 2009the semicolons should be changed to commas
template<class T1, class T2, class T3>