C++ Programming - Functions - Discussion
Discussion Forum : Functions - General Questions (Q.No. 15)
15.
Which of the following statement is correct?
Discussion:
9 comments Page 1 of 1.
Tushar kh said:
7 years ago
I agree with @Sushant.
Aakash Singh said:
8 years ago
Overloaded function always return, value of same data type.
Manpreet said:
1 decade ago
It is valid, but it will result in ambiguity.
Sonu Rajpoot said:
1 decade ago
Overloaded functions can accept same number of arguments or different number of arguments but make sure data type should be different.
Ganesh said:
1 decade ago
It is not compulsory every time argument list number are same.
Mahesh Dhumal said:
1 decade ago
Overloaded functions must differ from each other in number and/or type of argument in argument list.
Sushant Choudhary said:
1 decade ago
This is not right , in fact all options are incorrect, for option 1 the proof is:
#include<iostream>
using namespace std;
int foo(int x, int y){cout<<"foo with x="<<x<<"and y="<<y<<endl;};
int foo(int x, int y, int z){cout<<"foo with x="<<x<<",y="<<y<<",z="<<z<<endl;};
int main (){
foo(1,2);
foo(1,2,3);
return 0;
}
#include<iostream>
using namespace std;
int foo(int x, int y){cout<<"foo with x="<<x<<"and y="<<y<<endl;};
int foo(int x, int y, int z){cout<<"foo with x="<<x<<",y="<<y<<",z="<<z<<endl;};
int main (){
foo(1,2);
foo(1,2,3);
return 0;
}
Ankita said:
1 decade ago
Overloaded functions must differ from each other in number and/or type of argument in argument list.
(1)
Atul kumar said:
1 decade ago
Functions can be overloaded with same number of arguments but its type will be different.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers