answersLogoWhite

0


Best Answer

An alias is a reference, an alternate name for a variable or constant. You can assign the address of any variable or constant to a reference of the same type. A reference is a bit like a constant pointer to the type but, unlike a pointer, a reference has no address of its own thus you cannot store references. More importantly, references can never be NULL. They are simply an alternative name by which you can refer to an existing variable or constant. When you assign a value to an existing reference to a variable, you are assigning the value to the variable itself. When you pass a reference to a function, you are passing the address of the value being referred to, and that address is assigned to the function's reference argument and is local to the function. This is not unlike passing a pointer, but pointers may be NULL, references are guaranteed to be non-NULL (a NULL reference invalidates your program).

Note that C++ references are not the same as C reference variables or constants. In C, a reference variable is simply a non-const pointer, while a reference constant is a constant pointer. Hence pointers can be dereferenced (both in C and C++). But in C++, a reference is neither a variable nor a pointer, but is constant (it always refers to the same object and cannot be reassigned once assigned).

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is an alias name given to a variable in opp with c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Can a variable name can be passed to a value parameter in c plus plus?

No. Pass by value always receives a copy of the value being passed. Even if it were possible to physically pass a user-defined identifier into a function by value, the compiled code would not recognise the name since all identifiers are stripped out by the compiler and replaced with memory addresses. Strictly speaking, even pass by reference does not pass the variable name, as the function argument is simply an alias, an alternate but informal name, for the formal name you actually pass. In essence you are passing the memory address of the variable, rather the value of the memory address as you would with pass by value.


What makes for a good or bad variable name in C plus plus programming languages?

A good variable name is one that is clear, related to the data it stores. Also, you should try to avoid confusions with other variables.


How do you update a data file in c plus plus with a reference?

You cannot store references. A reference is nothing more than an alias, an alternate name for an existing variable or constant. References are primarily used when passing variables to functions such that the function can operate upon the variable itself -- known as passing by reference. The function refers to the variable by a different name, an alias, but it is the same variable. By contrast, when passing a variable by value the function uses a copy of that variable, assigning the variable's value to that copy. References are often confused with pointers, primarily because C uses the term to mean a pointer (hence the term, dereferencing). But in C++ a reference is a separate entity altogether. Unlike a reference, a pointer is a variable in its own right, one that can be used to store a memory address. Since a pointer has storage, you can store a pointer in a data file. However, in reality you are only storing the pointer's value -- a memory address -- not an actual pointer. Pointers and references are similar insofar as they can both refer to an object. A pointer does this by storing the memory address of the object, while a reference refers directly to the object itself. Thus if you have a pointer and a reference to the same object, the pointer's value is exactly the same as the address of the reference. Therefore the only way you can store a reference is by storing the object being referred to, not the reference itself.


Explain the scope and visibility of variables in c plus plus function?

If you define a variable inside of your function, the variable can be referred and used only inside of that function. It means that you will not able to use the variable in another function (including main). Area of code where your variable can be used after declaration is usually called visibility of the variable.


What is a primitive type variable in c plus plus?

same the types used in C. that is int...char...float...

Related questions

What does the variable equal in -2(-7k plus 4) plus 9-13?

The given expression can be simplified to: 14k-12


Can a variable name can be passed to a value parameter in c plus plus?

No. Pass by value always receives a copy of the value being passed. Even if it were possible to physically pass a user-defined identifier into a function by value, the compiled code would not recognise the name since all identifiers are stripped out by the compiler and replaced with memory addresses. Strictly speaking, even pass by reference does not pass the variable name, as the function argument is simply an alias, an alternate but informal name, for the formal name you actually pass. In essence you are passing the memory address of the variable, rather the value of the memory address as you would with pass by value.


Is the word main an illegal variable name in C PLUS PLUS?

I can tell you that it is not an illegal variable name in C. I do not currently have a C++ compiler installed, but I would assume that it would also be valid in C++.


What is is the variable for -6 plus x4 -5?

If you mean -6+4x-5 then the given expression can be simplified to 4x-11 and the unknown variable is x


What do you understand by constant and variable in c plus plus program?

A variable is any named value of a specified type that can hold any value of that type, and that can change that value at any time while the name is in scope. A constant is exactly the same as a variable except that its value must be set at the point of instantiation and the given value cannot be altered while the name remains in scope. In other words, a variable is a value that may vary while a constant is a value that always remains the same.


What makes for a good or bad variable name in C plus plus programming languages?

A good variable name is one that is clear, related to the data it stores. Also, you should try to avoid confusions with other variables.


What is swap in c plus plus programming language?

It is not a reserved word, so can be an identifier (name of a type/variable/function).


What is the variable of x plus 10 plus 4x-35?

What is the variable of x plus 10 plus 4x-35?


What does m equal in one fourths plus m equals?

In the statement given in the question, m is a variable with an unknown value.


Why does typing SHIFTf4name will not highlight or register as a variable in notepad plus plus coding in php?

In php a variable is declared using $ sign for eg. $name or $sport= 'Volleyball';. If you are not using this sign it won't work.


How do you define a symbol such as plus or - as a variable in python?

Use a character variable. For example: plus = '+' minus = '-' You can now refer to these symbols using the variable names "plus" or "minus".


What is x if x-4 plus 3x-1014?

The given expression can be simplified to 4x-1018 and the value of x is an unknown variable.