You are here:

C++/variables

Advertisement


Question
HI
i have a question about Design issues for all data types could you plz tell me about operations that define syntax of references to variables and how are they specified?
i dont know about these operations and their functions

Thanx
Bita

Answer
Dear Bita:

I am not sure what you are asking but I will guess.

I think you are asking what is the syntax for passing variables to a function by reference in C++.  Here is an example.

void A ( int & B )
{
 B = 2 ;
}

int C = 1 ;
A ( C ) ;

When control returns from A () the value of C will be 2.  When you use the ampersand (&) in this way it means you are passing by reference and not by value so the value of the variables in the function call may be changed by using the function.

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Titus B. Ledbetter, Jr.

Expertise

C , MFC, Object Oriented, Artificial Intelligence

Experience

I have over ten years experience in the field of Computer Science, five years experience developing C/C++. I recently wrote a chess program using Object Oriented, C++, MFC.

Education/Credentials
Master's Degree Computer Science from Johns Hopkins

©2016 About.com. All rights reserved.