You are here:



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



The syntax for a reference variable is used only on C++ function arguments.  There is no operator - reading and writing a reference variable is like reading or writing the variable used on the function call.  It is really like a shortcut - if you pass a variable by address and modify the variable through the pointer, it is just like a reference.  For example:

void RefFunction( int &i )

void PtrFunction( int *i )

void main( void )
int i = 4;

 RefFunction( i );
// i is 5 now
 PtrFunction( &i );  // Pass address of i to function
// i is 4 now

Note how the syntax is a little easier in the reference function.  But it is no more efficient than the function passing the address and using the * operator.

Hope this helps!


All Answers

Answers by Expert:

Ask Experts


Bill A


I can answer questions about C++, programming algorithms, Windows programming in MFC (which is C++). I cannot answer questions about STL (templates) and I have no experience with Linux. I do enjoy reviewing code and critiquing it or finding problems in it. I will also gladly show better algorithms or methods if you want to take advantage of that.


I've developed a commercial embedded C compiler/assembler and IDE with debugger toolset, of which the IDE and debugger are written in C++. I work in the industry writing high tech embedded programs and Windows programs to communicate with the embedded devices.

Book: Embedded Systems Design using the Rabbit 3000 Microprocessor Authored Chapter 10 in its entirety.

BS Computer Engineering

©2017 All rights reserved.

[an error occurred while processing this directive]