Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews C Plus Plus Language Interviews:C++ Access ControlC++ COM ActiveXC++ ConstructorsC++ ContainersC++ Exception HandlingC++ FriendC++ InheritanceC++ Inline FunctionC++ New And DeleteC++ Operator OverloadingC++ Pointers & FunctionsC++ ProgrammerC++ ReferencesC++ Static DataC++ SyntaxC++ TemplateC++ Type CheckingC++ Virtual Functions
Copyright © 2018. All Rights Reserved
C++ Programmer Interview Question:
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
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.