Forgot your password?  

Not What You Meant?  There are 15 definitions for Constant.

Constant Reference | Research & Encyclopedia Articles

Print-Friendly   Order the PDF version   Order the RTF version
About 1 pages (297 words)
Constant function Summary

 


Constant Reference

A constant reference parameter is a term relevant to computer programming. The parameter allows a programmer to protect the data that has been sent to a function, so that the function cannot alter the data. This is possible because it is the address of the data that is actually sent to the function, not a copy of the data itself. When the function is executed, the data at the supplied address is used.

The preservation of data can also be achieved by the use of a so-called value mechanism. However, this latter mechanism requires more memory than does the use of a constant reference parameter, because it requires data to be copied. Since the constant reference parameter operates by supplying the address of data, not the data itself, less memory is required.

A constant reference parameter operates by the use of the modifier "const" in the encoded function definition. For example, the following function definition is a reference parameter, which can alter the value of the data it is commanded to obtain: void GetData (double &Num3, int &Num4). Any change made to the values referred to by the parameter nametags is also a change in the value referred to by the any arguments that are written. This is because the parameter and argument are directed to the same location in memory. In contrast, the function definition of a constant reference parameter would be written as: void GetDouble (double &Num3, const int &Num4). The use of the "const" designation has modified the function so that the data cannot be changed, by allowing the parameter and the argument to have the same memory location.

Constant reference parameters are utilized with programming components, primarily for structured object such as structs, classes, and arrays. Object-oriented languages such as C++ utilize constant reference parameters.

This is the complete article, containing 297 words (approx. 1 page at 300 words per page).

Ask any question on Constant function and get it answered FAST!
Answer questions in BookRags Q&A and earn points toward
discounted or even FREE Study Guides and other BookRags products!
Learn more about BookRags Q&A
Copyrights
Constant Reference from World of Computer Science. ©2005-2006 Thomson Gale, a part of the Thomson Corporation. All rights reserved.

Join BookRagslearn moreJoin BookRags

Join BookRagslearn moreJoin BookRags