-
Junior Member
returntype
can a function return two values?
-
Contributing Member
Re: returntype
No Java does not allow returning multiple values. Only one value can be returned by a method in Java. Also one more additional thing to know in Java regarding passing of value to methods is everything in Java is passed by value.
-
Junior Member
Re: returntype
Not only in Java in all programming languages function returns ONLY one value.
-
Junior Member
Re: returntype
//from one functions returning 2 values
#include<iostream.h>
#include<conio.h>
int fun(int &x,int a,int b)
{
cout<<x<<" "<<&x<<endl;
x=a+b;
return a;
}
void main()
{
clrscr();
int fun(int &x,int a,int b);
int y=10;
cout<<fun(y,1,2)<<endl;
cout<<y<<" "<<&y<<endl;
getch();
}
//It returns values by reference,
//It's modifying another value. But there's return a;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules