Is it possible to define a function of type "float array" ?

Is it possible to define a function which returns a multidimensional array?
I tried:

float[5][5] array_fun(float a1, float a2){

The compiler says that I want to declare a function that returns an array
but does not compile.

Is it possible to do this in c++?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You need to return either pointer to pointer or do typedef...

float** array_fn1(float a1, float a2);

typedef float floatMatrix[5][5];
floatMatrix array_fn2(float a1, float a2);
Actually, you can't return an array. You could only return pointer or a reference to it.
eyuchenAuthor Commented:
Is there any particular reason or philosophy that c++ does not allow this kind of
function type?

It seems that my compiler know exactly what I want but just doesn't allow me to do this...
kind of strange on my point of view--if the compiler understands, this must be something
that many ppl have tried to achieve.

(my compiler returns something like, error: trying to declare function with return type array)
Well, for exact reason we would need to ask Bjarne Stroustrup but C++ doesn't allow the copying of one array variable to another array variable. We have to do it element by element. For return this coping would be required and that is probably why it is not allowed.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.