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++ Operator Overloading Interview Question:
What is overloading template?
Submitted by: AdministratorA template function overloads itself as needed. But we can explicitly overload it too. Overloading a function template means having different sets of function templates which differ in their parameter list. Consider following example:
#include <iostream>
template <class X> void func(X a)
{
// Function code;
cout <<”Inside f(X a) n”;
}
template <class X, class Y> void func(X a, Y b) //overloading function template func()
{
// Function code;
cout <<”Inside f(X a, Y b) n”;
}
int main()
{
func(10); // calls func(X a)
func(10, 20); // calls func(X a, Y b)
return 0;
}
Submitted by: Administrator
#include <iostream>
template <class X> void func(X a)
{
// Function code;
cout <<”Inside f(X a) n”;
}
template <class X, class Y> void func(X a, Y b) //overloading function template func()
{
// Function code;
cout <<”Inside f(X a, Y b) n”;
}
int main()
{
func(10); // calls func(X a)
func(10, 20); // calls func(X a, Y b)
return 0;
}
Submitted by: Administrator
Copyright 2007-2025 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.

https://InterviewQuestionsAnswers.ORG.
