answersLogoWhite

0


Best Answer

Call by reference does not necessarily mean you want to change something. It simply means that you are passing a pointer to the object rather than the object itself. This can be cost effective if the object is large, in comparison to a pointer. Making the call by reference const is an effective tool for doing this when you do not intend to modify the object, and you want to make sure you don't accidentally do so.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why you pass something by reference and then make it const while call by reference mean you want to change it?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

The cell reference that changes authomatically while copying formula?

A relative reference will change and a mixed reference will partially change. See the related question below.


Is a variable a thing that can change?

A variable change such as ice melting into water, which can be frozen again into ice later on is called a physical change. while a permanent change such as growing of a tree is called a chemical change


What were the view points on the federalists?

The Federalists supported strong federal/central government, while the antifederalists wanted strong state government.


An array name is a pointer constant?

An array's name is not a constant pointer; it's not even a pointer! An array name is a reference to the array itself. Unlike pointers, references have no memory of their own, therefore a reference cannot be constant (only what it refers to can be constant). A reference is nothing more than an alias for a memory address. Since there is no separate storage for references, you cannot reassign references while they remain in scope. So, in that sense, it behaves like a constant pointer. But a pointer is a variable, so even if declared const, it requires memory of its own in order to store the memory address it points to.Example:int a[10];int * const p = a; // const pointerassert( *p &a ); would cause an assertion. Likewise, assert( p != &p); proves that p must reside in a separate memory address from that referred to by a. It has to: pointers are variables even when they are declared const.


How the const volatile int is different from volatile int?

All const does is prevent wou from using the variable to which it applies as an L-Value (on the left of an assignment). That is to say, if you declare something as const the compiler will flag an error if you then try to modify it. if you declare somthing as volitile, it means that it could be changed by something other than the immediate code which is executing, such as another thread or a hardware device, thus informing the compiler to refrain from performing optimisations such as the following. ORIGINAL CODE: bool aCondition = true; while (aCondition); AFTER OPTIMISATION: bool aCondition = true; while (true); In the example above the compiler nitices that the condition is true imediatly before entering the while loop and therefore substututes the test for an unconditional infinte loop. if on the other hand the code looked like this: volitile bool aCondition = true; while (aCondition); the compiler would refrain from performing the previous optimisation in the knowlege that the value of aCondition (having been declared as volitile) may change and the loop must therefore not be assumed to be unconditionaly infinite.


What is difference between constant in c plus plus and final in java?

The final keyword can be used to modify a class, method, or variable.When used on a variable, it means that variable cannot be changed once set.When used on a method, it means that no subclasses may override that method.


How would you change b9 to an absolute cell reference?

You would put a dollar before the B and before the 9, like this: $B$9 It can be done by pressing the F4 key, while entering the reference.


What Keeps a cell reference constant when copying a formula or function?

If you want to copy a formula from one cell to another (or fill down) without Excel changing the cell references automatically, you'll need to write the cell references with dollar signs included for absolute referencing. Eg: the reference '$D3' locks the reference to column 'D' but allows the row to change when the cell is copied. Eg: the reference 'D$3' locks the reference to row '3' but allows the column to change when the cell is copied. Eg: the reference '$D$3' locks the reference to column 'D' and row '3', so the cell reference cannot change at all when the cell is copied. While you are typing in a cell reference, pressing the 'F4' key will cycle through the combinations for you, so you don't need to type the dollar signs yourself.


What are constants for in Excel?

Constants are fixed values, so they never change. They are used in formulas where you know a particular value does not change. If you have a formula that is always going to multiply something by 2, then the 2 is a fixed value and can be entered into the formula as a constant, while the other value will be a cell reference, so it can have a variable value, like in the following formula. =H5 * 2


How do you change a relative cell reference into an abosolute cell reference?

You can type in the dollars before the column and row in the cell reference, so A3 could become $A$3 in the formula. While you are typing a cell reference in a formula, pressing the F4 key will cycle through the relative, absolute and mixed cell references, so that is another way of doing it.


C programming copying of two strings?

/* this is the same functionality as strcpy() */ /* note that this, like strcpy, is not buffer overrun safe */ char *StringCopy (char *destination, const char *source) { const char *temp = destination; while ((*destination++ = *source++) != '\0'); return temp; }


Why is the creation of a mixture considered a physical change not a chemical change?

It depends on the mixture a physical change would just be a change in appearance while the chemical change would alter is ingredients and make it something different