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: MuhammadImplement 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
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
Top C++ Programmer Questions
☺ | Explain me what is an Object/Instance? |
☺ | Explain void free (void* ptr)? |
☺ | Tell me how to create a pure virtual function? |
☺ | Tell me what will the line of code below print out and why? |
☺ | Please explain is there a difference between class and struct? |
Top C Plus Plus Language Categories
☺ | C++ Pointers & Functions Interview Questions. |
☺ | C++ Operator Overloading Interview Questions. |
☺ | C++ Exception Handling Interview Questions. |
☺ | C++ Template Interview Questions. |
☺ | C++ Virtual Functions Interview Questions. |