answersLogoWhite

0


Best Answer

Any name can be placed in an array, be it a primitive name or an object name, even a function pointer. Four examples of common objects that may be placed in an array include any object defined in the STL (standard template library), which includes vectors, lists, iterators and maps. All are self-explanatory, although a vector is simply an array implemented as an object. Therefore an array of vectors is nothing more than an array of arrays (effectively a multi-dimensional array). However, vectors are the "correct" way of implementing arrays in C++ (unless you specifically wish to use C-style code in your C++ projects), thus a multi-dimensional array is best implemented as a vector of vectors.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: The most common function of an array is to store variables however there will be times when an array is used to store objects. briefly describe four such objects?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are local variables and global variables?

Local variables: These variables only exist inside the specific function that creates them. They are unknown to other functions and to the main program. As such, they are normally implemented using a stack. Local variables cease to exist once the function that created them is completed. They are recreated each time a function is executed or called. Global variables: These variables can be accessed (ie known) by any function comprising the program. They are implemented by associating memory locations with variable names. They do not get recreated if the function is recalled.


What is a variable that is used within a function?

If the variable is declared within the function body, it is a local variable, one that is local to the function. Local variables fall from scope when the function returns, they are only accessible within the function. However, local variables can be returned by value, which creates an automatic variable that is returned to the caller. If the caller does not store the return value, the automatic variable falls from scope when the expression containing the function call ends. However, the expression may evaluate the return value without storing it. Note that functions cannot return local variables by reference since the local variable falls from scope when the function returns. If the variable is passed as an argument to the function, then the variable is a parameter of the function. Arguments may be passed by value or by reference, depending upon the function signature. Passing by value means the function parameter is a copy of the argument (if the argument is an object, the object's copy constructor is invoked automatically). Thus any changes made to the parameter within the function are not reflected in the argument that was originally passed, and the parameter will fall from scope when the function returns. However, the value of the parameter can be returned as previously explained. Passing by reference means the function parameter refers directly to the argument that was passed. Thus any changes made to the parameter are reflected in the argument. Parameters that are declared as constant references assure the caller that the reference's immutable members will not be altered by the function. If the parameter is a non-const reference but the caller does not wish changes to be reflected in the argument, the caller should pass a copy of the argument instead.


Does there exist any way to make the command line argument available to other function without passing them as arrguments to function?

The only way this can be achieved is by storing the command line arguments in global variables. However, this is not recommended. Global variables should only be used to represent truly global concepts, but command line arguments are local to the main function. The main function's primary role is to parse the command line arguments and invoke the appropriate functions, passing any required arguments (by value) to those functions that specifically require them. The main function's secondary role is to handle any exceptions not handled by the functions that it invokes.


Should you avoid local variable scope?

No. In most designs, local variables are considered a good thing thanks to the isolation that they provide (no other code can "abuse" your variable). However, it is important to distinguish between local static variables, local automatic variables, and locally made references to the heap. Local static variables are initialized only once at application initialization time, and retain their most recently assigned value over multiple invocations of the function which contains them. Local static variables must be used with care and can lead to non-reentrant code (the famous example being the strtok() CRT function). However, these variables are usually great to track the total number of something, or the minimum or maximum value of a particular item, etc. In C, local automatic variables are the most common form of local variables. These are typically allocated on the stack, so care must be taken when declaring large automatic variables, or when using recursion. When the size of a local automatic variable is a concern, dynamic memory management method should be considered those maintain a local auto pointer on the stack but place the data in the heap. This method allows to allocate large amounts of data without burden on the stack, and the lifetime of such data is no longer limited by the lifetime of the scope in which it was allocated. Very rare cases exist where local variables are generally avoided; these are mostly in the area of very resource limited embedded programming.


Can static member function be overloaded?

Yes. Any function can be overloaded. However you cannot override a static member function. Only instance members can be overridden.

Related questions

Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?

You can copy them into global variables in the main() function, then have your other functions access those global variables. Global variables should generally be avoided, however.


Can the function Qd equals -30p plus 0.5y plus 2Pr plus 4T be graph?

Since the function depends on 4 variables (assuming that p and P are the same variable), the full graph would require 5 dimensions. You can, however, graph something like a cross-section for the graph, in the sense that you keep most of the variables constant, and study the dependency of the function on a single variable at a time.


What are local variables and global variables?

Local variables: These variables only exist inside the specific function that creates them. They are unknown to other functions and to the main program. As such, they are normally implemented using a stack. Local variables cease to exist once the function that created them is completed. They are recreated each time a function is executed or called. Global variables: These variables can be accessed (ie known) by any function comprising the program. They are implemented by associating memory locations with variable names. They do not get recreated if the function is recalled.


What is the intercept of 6x-5y equals 60?

If there are two variables, you need two equations to find the variable. however, the function would be this: y = 6/5x - 12 seriously though, what grade are you in anyways? sixth?


What is a variable that is used within a function?

If the variable is declared within the function body, it is a local variable, one that is local to the function. Local variables fall from scope when the function returns, they are only accessible within the function. However, local variables can be returned by value, which creates an automatic variable that is returned to the caller. If the caller does not store the return value, the automatic variable falls from scope when the expression containing the function call ends. However, the expression may evaluate the return value without storing it. Note that functions cannot return local variables by reference since the local variable falls from scope when the function returns. If the variable is passed as an argument to the function, then the variable is a parameter of the function. Arguments may be passed by value or by reference, depending upon the function signature. Passing by value means the function parameter is a copy of the argument (if the argument is an object, the object's copy constructor is invoked automatically). Thus any changes made to the parameter within the function are not reflected in the argument that was originally passed, and the parameter will fall from scope when the function returns. However, the value of the parameter can be returned as previously explained. Passing by reference means the function parameter refers directly to the argument that was passed. Thus any changes made to the parameter are reflected in the argument. Parameters that are declared as constant references assure the caller that the reference's immutable members will not be altered by the function. If the parameter is a non-const reference but the caller does not wish changes to be reflected in the argument, the caller should pass a copy of the argument instead.


What value is stored in uninitialized variables?

Some languages assign a default value as 0 to uninitialized variables. In many languages, however, uninitialized variables hold unpredictable values.


Does there exist any way to make the command line argument available to other function without passing them as arrguments to function?

The only way this can be achieved is by storing the command line arguments in global variables. However, this is not recommended. Global variables should only be used to represent truly global concepts, but command line arguments are local to the main function. The main function's primary role is to parse the command line arguments and invoke the appropriate functions, passing any required arguments (by value) to those functions that specifically require them. The main function's secondary role is to handle any exceptions not handled by the functions that it invokes.


What is the act of speech?

There is no piece of legislation called the Category of Speech Act. However, a speech act is a linguistics term used to describe an utterance that has a function as a performance of communicating something.


Briefly describe the possible hazards of working with a 0.5M NaOH solution.?

It is a mild irritant at this concentration; however, the greatest danger is to the eyes. Use precautionary measures by wearing protective goggles, but if the solution does get into the eyes, flush immediately at the eye-wash station in your lab.


The probability of getting into a car accident as a function at the speed of which you drive?

No function can get us a right or even close answer, this is all dependent on infinite number of variables. however, lower speeds reduces the probability in known factor. But more important it will decrease the damage to human in case accident happened. be safe and drive slowly.


Where can one learn about partial differential equations?

Partial differential equations are mathematical equations that involve two or more independent variables, an unknown function, and partial derivatives of the unknown function. Even the explanation is confusing! If, however, anyone chooses to learn about PDE there are classes offered at any institution of higher learning.


What Is The Category of Speech Act?

Speech acts are categorized into three main types: locutionary acts (the actual utterance itself), illocutionary acts (the intention behind the utterance), and perlocutionary acts (the effect the utterance has on the listener or recipient). These categories help to understand the different layers of communication involved in an utterance.