Tell us how to make sure a C++ function can be called as e.g. void foo(int, int) but not as any other type like void foo(long, long)?

Submitted by: Muhammad
Implement foo(int, int)…

void foo(int a, int b) {
// whatever
}
…and delete all others through a template:

template <typename T1, typename T2> void foo(T1 a, T2 b) = delete;
Or without the delete keyword:

template <class T, class U>
void f(T arg1, U arg2);

template <>
void f(int arg1, int arg2)
{
//...
}
Submitted by: Muhammad

Read Online C++ Programmer Job Interview Questions And Answers