|
-
July 18th, 2002, 01:21 PM
#1
Function Pointer
I do have a function pointer. See the code below. I thought it is unecessary to define the variable as the return value. What can I do to make it better. For example, let the function return itself, which is impossible to my knowledge. For examjple,
return add number
or return (*x + y) something like that
how can I do that
#include <iostream.h>
#include <conio.h>
int *AddNumber(int *x, int *y)
{
int i;
int *z;
const int k=5;
for (i=0;i<k;i++)
{
z[i] = x[i] + y[i];
}
return z;
}
void main()
{
int x[5] = {0,2,4,6,8};
int y[5] = {1,2,3,4,5};
int i, *z;
z = AddNumber(x,y);
for (i=0;i<5;i++)
{
cout<<z[i];
cout<<endl;
}
getch();
}
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
|
Click Here to Expand Forum to Full Width
|