by Richard Heathfield <rjh@[EMAIL PROTECTED]
>
Apr 14, 2008 at 11:01 AM
cplusplusquestion@[EMAIL PROTECTED]
said:
> const int MAX=20;
> int a[MAX];
I don't know whether that's legal C++. It's legal C99, but not legal C90.
>
> int* return_a_value(){
> return a;
>
> }
>
> int main(){
> for(int i=0; i<MAX; i++)
> a[i] = 2;
> int* b = return_a_value();
>
> for(int i=0; i<MAX; i++)
> cout << b[i] << " "; // DOES this right?
Because b[i] means the same as *(b + i), yes, that works just fine in C++,
provided cout is defined appropriately.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www.
+rjh@[EMAIL PROTECTED]
users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999