Reference variables

Reference variable behave similar to both, a value variable and a pointer variable. Value variable are used to hold some numeric values, pointer variable are used to hold the address of some other variable. In programme code reference variable is used similar to that of a value variable but has an action of a pointer variable." Reference variable benefits from the simplicity of the value variable and power of pointer variable". It does provide the flexibility supported by the pointer variable, unlike pointer when a reference is bound to a variable, then its binding cannot be changed. All the accesses made to the reference variable as same as to the access to which it is bound. The general format of declaring reference variable is:

 

Data type and reference variable + value variable

Where data type can be standard or user defined type:

Like Int, char, float etc.

& reference operator

The reference variable must be initialized to same variable only at the point of its declaration. Initialization of reference variable following its declaration sources compilation error.

 




 

   Related Questions in Programming Languages

  • Q : Examples of applications which can

    Give some examples of applications which can benefit from using XML?

  • Q : Define the term Condition Define the

    Define the term Condition: It is a Boolean expression which controls a conditional statement or loop.

  • Q : What is Pointer Arithmetic Pointer

    Pointer Arithmetic: C and C++ provide the ability to modify a pointer’s target address with arithmetic operations. This is used, for example, to index arrays. MyObject* P = ...

    Q : Friend function in C++ Q. What is

  • Q : What do you mean by process What do you

    What do you mean by the term process? Illustrate briefly.

  • Q : Explain Look-and-feel Look-and-feel :

    Look-and-feel: The visual impression and interaction style given by a user interface. This is mainly the responsibility of the window manager (that is, in collaboration with the fundamental operating system) running on a specific computer. This refers

  • Q : Features of WordPress Normal 0 false

    Normal 0 false false

  • Q : What is Linux Write down about Linux?

    Write down about Linux?

  • Q : Function prototypes Function prototypes

    Function prototypes: Function declaration which specifies the function name, return type and parameter list of the function. Syntax: return_type function_name(type var1, type var2,…

  • Q : Use Polymorphism Use Polymorphism :

    Use Polymorphism: Programs, especially those converted from non-OOP languages like C, sometimes use state where they should use inheritance. For example,

    Discover Q & A

    Leading Solution Library
    Avail More Than 1455547 Solved problems, classrooms assignments, textbook's solutions, for quick Downloads
    No hassle, Instant Access
    Start Discovering

    18,76,764

    1944221
    Asked

    3,689

    Active Tutors

    1455547

    Questions
    Answered

    Start Excelling in your courses, Ask an Expert and get answers for your homework and assignments!!

    Submit Assignment

    ©TutorsGlobe All rights reserved 2022-2023.