Technical Interview

Home
Technical Interview
Interview Process
Introduction Questions
Quantitative Problems
Google & Microsoft
Algorithms
C/C++ Questions
Java Questions
Data Structures
Fundamental Questions
Puzzles
Resume Tips
Added Recently
Links
Contact Us
Submit Question/Answer

Can you overload a function with the return type?

What is the output of the program below? Why?
Class A
{
public:
void func();
};
class B:pubic A
{
void func(int a);
};
int main()
{
B derv;
derv.func();
}

 

The output will be a compile error because B doesn't know the definition of func().

To make this program run . Rewrite it as:


Class A
{
public:
void func();
};
class B:pubic A
{
using A::func();
void func(int a);
};
int main()
{
B derv;
derv.func();
}