You define a structure type globally because

you save many lines of code by not rewriting an identical structure definition in each function that uses it
you will never change its definition
it is required in C++
all of the above

The correct answer is: A. you save many lines of code by not rewriting an identical structure definition in each function that uses it.

A structure type is a user-defined data type that can be used to group together related data items. It is defined using the struct keyword. The structure definition is followed by a list of members, which are the data items that will be grouped together. Each member has a name and a data type.

A structure type can be used in a program in the same way as a built-in data type, such as an integer or a float. It can be declared as a variable, passed as an argument to a function, or returned from a function.

When a structure type is defined globally, it means that it is available to all functions in the program. This can be useful if the structure type is used by many different functions. It can also save lines of code, because the structure definition does not need to be repeated in each function that uses it.

The other options are not correct. Option B is incorrect because the structure definition can be changed even if it is defined globally. Option C is incorrect because it is not required to define a structure type globally in C++. Option D is incorrect because only option A is correct.

Exit mobile version