Topic: Decay of array to pointer


Author: "Robert Stafford" <stafford@bindview.com>
Date: 1998/09/21
Raw View
Are the two function declarations

int f(char a[25]);

and

int f(char* a);

distinct?  That is, is the second a redeclaration of the first, or may we,
in essence, overload on array length?
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Alexandre Oliva <oliva@dcc.unicamp.br>
Date: 1998/09/21
Raw View
Robert Stafford <stafford@bindview.com> writes:

> Are the two function declarations
> int f(char a[25]);

> and

> int f(char* a);

> distinct?

No, they are just duplicate declarations of the same function.

> That is, is the second a redeclaration of the first, or may we,
> in essence, overload on array length?

You can onverload on array length, but only if you pass the array by
reference:

int f(char (&a)[13]);

--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]