If the following code is legal, what can we infer about the return type of f?
That it returns a pointer to a double:
double *f()
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
*/
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314