If the following code is legal, what can we infer about the return type of f?
That it returns a pointer to a double:
Possible usage:
#include <iostream>
double *f()
{
static double value[] = {1,2,3,4,5};
return value;
}
int main ( void )
{
int n = 2;
double d = f() [n];
std::cout << "d = " << d << '\n';
return 0;
}
/* my output
d = 3
*/
Reputation Points: 2780
Solved Threads: 312
long time no c
Offline 4,790 posts
since Apr 2004