answersLogoWhite

0


Best Answer

What 'references' and what 'aliases'? Try to rephrase your question.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Which category of c references are always aliases?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is actually passed to a function when an object is passed to a function through a pointer?

When an object is passed to a function by pointer, a copy of the pointer's value is passed to the function. Pointers are always passed by value, but because the value is a memory address than can be dereferenced, they enable us to pass objects by reference. In languages such as C which have no concept of references, this was the only way to pass by reference. C++ introduced proper references (aliases for existing objects), thus when we want to pass by reference we can choose to use a pointer or an actual reference. Normally we'd only pass by pointer when passing an optional argument that defaults to NULL when no argument is given. Otherwise we pass by reference because references can never be NULL.


Are reference variables are NOT available in C?

Yes, reference variables are permitted in C. However a reference variable in C is simply another name for a pointer variable, because pointers can be dereferenced to allow indirect access to the memory they point at. However, in C++, references are neither pointers nor variables, they serve another purpose altogether, one which is not available in C. So the real answer is that C++ references are not available in C, but reference variables are. Although it is common practice to avoid using the term reference lest there be any confusion with a C++ reference, it doesn't alter the fact that a C pointer variable is also a C reference variable. They are one and the same thing. In C++, a reference is entirely different from a C reference. More specifically, it is an alias, an alternate name, for a memory address. Unlike pointer variables, a reference consumes no memory of its own. That is, you cannot obtain the address of a reference since there is none to obtain. Hence the 'address of' operator (&) is used during instantiation to signify that the instance name is actually a reference of the specified type, and not a variable of the type. The address being referred to must also be assigned to the reference when the reference is instantiated. That is, you cannot declare a reference and then assign a memory address to it elsewhere in your code. By the same token, you cannot subsequently reassign a reference while it remains in scope. Remember, references are not variables. What they refer to may be variable, but not the reference itself. In that respect it is not unlike like a constant pointer to a variable. References allow you to refer to the same memory address using one or more aliases. Since they consume no memory of their own, there is no practical limit to the number of aliases you can have in your C++ program. When compiled, all references to the same memory are effectively replaced with the actual memory address, or the address of a static location containing the actual memory address if the address was allocated dynamically. So while references are often implemented just as if they were pointers, this is only of concern to developers of C++ compilers. In more general C++ source code, the two concepts must be kept distinct. C++ references are also much easier to work with than pointers. Whereas pointers to allocated memory must be manually released when no longer required, references do not. When a referenced object falls from scope, the object's destructor is called automatically. More importantly, references can never be NULL so, if you have a reference, a valid object of the specified type is guaranteed to exist at the referred memory location. The only time you will encounter problems with references is when you point at them, and then delete the pointer! If you subsequently access the referenced memory or the reference falls from scope, your program will exhibit undefined behaviour. Obviously this is a programming error, but these type of problems exist with pointers in general, hence pointers are best avoided as much as is possible. If an object is guaranteed to exist, then refer to it, don't point at it. Only use a pointer when an object is not guaranteed to exist, or if you need to change the address being referred to. And if a pointer is non-NULL, refer to the object.


What are C reserved words?

C reserved words are words which cannot be used as names. This includes all the built-in type names, including int, char and double and their aliases, the modifiers long, short, signed and unsigned, and all language keywords such as if, else, for, while, return and so on.


What is an alias name given to a variable in opp with c plus plus?

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).


What is self referential function in c plus plus?

A self-referential function in C++, or in any other supporting language, is a recursive function.

Related questions

How do you write a reverse function in C plus plus without pointers?

You can either use references or you can simply return the result by value. Note that in C++, unlike C, references are not the same as pointers. C++ references are aliases, alternate names for existing objects, whereas pointers are just variables that may contain a memory address that can be dereferenced.


What is actually passed to a function when an object is passed to a function through a pointer?

When an object is passed to a function by pointer, a copy of the pointer's value is passed to the function. Pointers are always passed by value, but because the value is a memory address than can be dereferenced, they enable us to pass objects by reference. In languages such as C which have no concept of references, this was the only way to pass by reference. C++ introduced proper references (aliases for existing objects), thus when we want to pass by reference we can choose to use a pointer or an actual reference. Normally we'd only pass by pointer when passing an optional argument that defaults to NULL when no argument is given. Otherwise we pass by reference because references can never be NULL.


Which category is Aburaman senior high fall under?

category c


How do you spell references?

The word "references" is spelled R-E-F-E-R-E-N-C-E-S.


Which is the safest pregnancy category?

c


What does pimp c sweet Jones mean?

"Pimp C" is the stage name of Chad Butler, a rapper and member of the group UGK. "Sweet Jones" was his alias, paying homage to the legendary pimp culture of the 1970s. The combination of the two names symbolizes his persona as a street-smart, smooth-talking individual with a strong presence in the rap scene.


What is category c?

Need more info.


How do we add the C plus plus category in Netbeans?

To use C++ in Netbeans you will need a C++ compiler.


What does the drug category C for pregnancy consist of?

Category C: No adequate human or animal studies; or adverse fetal effects in animal studies, but no available human data.


What is an easy way to verify that a formula references the cells that you want it to reference in excel?

Use absolute references (e.g. $C$3) instead of relative references (e.g. C3). See related questions for more information about absolute references.


Which of the six categories of HAZMAT is made of acids and alkalis?

Category C Category A is flammable Category B is toxic Category D is oxidizing material Category E is aerosols Category F is compressed gas source of the answer is http://motomom.tripod.com/110esws


How can you use praliases to regenerate a lost aliases file in Linux?

# /usr/sbin/praliases | head -5postmaster: rootdaemon MORE?OR touch dd= C /sbin/var/etc/config.you