John said:
BTW in 'float someFunction(float x[])' x is *not* an array, it is a
pointer, it is exactly the same as if you had written 'float
someFunction(float* x)'. You should prefer the second form because it
doesn't try to pretend that x is an array when it isn't.
I think that this is stylistic, and John shouldn't try and force saying
that one representation is better than the other. I personally would
say that using 'float someFunction(float x[])' is better because it
describes the /intent/ of what is being passed, an array. 'float
someFunction(float* x)' however describes an intent of passing only one
value, unless backup with documentation.
However, using only one parameter showing the intent of passing an array
had better be backed up with either a terminator value element or a size
parameter.
If the size is immutable, then perhaps an array reference as Alf
described would be in order, i.e. ('float someFunction(float (&x)[20])'.
If it can take many different sizes, then a template may be good,
depending on how many you are considering.
The original question, which turned out to be a function pointer that
took a float array as a parameter, was determined to be stylistically
just bad though, since no terminator value was specified and it was not
anchored to any particular number of elements.
Any comments?
Adrian
--
==========================================================
Adrian Hawryluk BSc. Computer Science
----------------------------------------------------------
Specialising in: OOD Methodologies in UML
OOP Methodologies in C, C++ and more
RT Embedded Programming
__--------------------------------------------------__
----- [blog:
http://adrians-musings.blogspot.com/] -----
'--------------------------------------------------------'
My newsgroup writings are licensed under the Creative
Commons Attribution-Noncommercial-Share Alike 3.0 License
http://creativecommons.org/licenses/by-nc-sa/3.0/
==========================================================