Arrays & Structures

kanaks_go4ex's Avatar, Join Date: Jun 2008
Go4Expert Member
Can structures be passed to the functions by value?

Why cannot arrays be passed by values to functions?

Please explain.
0
oogabooga's Avatar
Ambitious contributor
Yes, you can pass a struct by value, but it is rarely done.

Presumably arrays cannot be passed by value for two reasons:
  1. Arrays can be huge, and since passing by value means
    making a copy of it, it would be very inefficient.
  2. The compiler does not know the size of a dynamic array.
Actually, you can put a (non-dynamic) array into a struct
and pass it by value that way!
0
kanaks_go4ex's Avatar, Join Date: Jun 2008
Go4Expert Member
can u give me an example for both the cases.
thanx a lot.