Structure
Structure
13
Prepared by Nega Teferra (M.Tech on CSE)
Array within Structures
A structure is a data type in C++ that allows a group of
related variables to be treated as a single unit instead of
separate entities.
A structure may contain elements of different data types
– int, char, float, double, etc.
It may also contain an array as its member.
Such an array is called an array within a structure.
An array within a structure is a member of the structure
and can be accessed just as we access other elements of
the structure.
dt_ptr -> yy
and
dt_ptr -> dd
25
Prepared by Nega Teferra (M.Tech on CSE)
Passing by Reference
In passing by reference, the address of a structure
variable is passed to a function.
In this, if we change the structure variable which is inside
the function, the original structure variable which is used
for calling the function changes.
This was not the case in calling by value.
This case is similar to the previous one, the only
difference is that this time, we are passing the address of
the structure variable to the function.
While declaring the function, we passed the pointer of the
copy the structure variable' in its parameter.