What does the indirection operator do?
Pointer:
Pointer, the name itself references the purpose of the pointer. Pointers point to a location in memory.
- Pointer is a special type of variable to store the address of the memory location, which can be accessed later.
- If an asterisk “*” operator is present before the variable, then that variable is referred as pointer variable.
- Pointer is just a type of variable that stores the addresses of other variables.
- Using pointers, we can access the address of a variable; the data stored in that variable can be retrieved.
Syntax of pointer variable declaration:
<variable-type> *<variable-name>;
Example for pointer variable declaration:
//definition of pointer variable
int *ptrvar;
Where,
- “int” is the variable type.
- “*ptrvar” is the pointer variable name.
Explanation of Solution
Indirection operator:
An asterisk “*” is also referred as indirection operator which is used to dereferences the pointer.
Consider the following statements
//declare variable x
//assign the value 7 to y
int y = 2;
//declare pointer variable
//store the address of y in ptrvar
int *ptrvar = &y;
Here, the variable “y” is pointed by the pointer variable “ptrvar”. And “ptrvar” is used to change the value of the variable “y”.
- Hence, the user can work with the value the pointer is pointing to.
Want to see more full solutions like this?
Chapter 9 Solutions
EBK STARTING OUT WITH C++ FROM CONTROL
Additional Engineering Textbook Solutions
C How to Program (8th Edition)
Java How To Program (Early Objects)
Web Development and Design Foundations with HTML5 (8th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
- When a function can take another function as a parameter, how can type-checking occur?arrow_forwardThe friend function is incompatible with the goal of encapsulation. Also, talk about the many applications for the friend function that you have.arrow_forwardThere are no restrictions on how an overloaded operator may be implemented. Falsely Accuratearrow_forward
- What are overloading operators? How is this similar or different to overloading functions and methods?arrow_forwardYOu WIll Lose Data Divisibility Test A number x is said to be divisible by a number y if when x is divided by y (x%y) the remainder is zero. A number is said to be a prime number if it is divisible by 1 and by iself only. Write a menu-driven program in C++ using a class with two overloaded functions divide(). Based on the choice given by the user any one of the two functions must get invoked. One function needs to chech for the divisibility of a number by another number and another divide() function needs to check whether a number is prime or composite. Functions are said to be overloaded when their names are same. But the functions must differ in their signature. For example : If Choice is 1 then the function to check for divisibility gets invoked. stv Denominator must be checked for "Divisible By Zero" exception. If numerator = 10 and denominator = 5 then 10 is divisible by 5 If numerator = 11 and denominator =5 then 11 is not divisible by 5 In the main function at the end of the…arrow_forwardWhat is an increment operator?arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT