Concept explainers
Pointer:
Pointer will allow the user to indirectly access and manipulate the variable data contents. A pointer variable will hold the address of the data contents. If an asterisk “*” operator is present before the variable then that variable is referred as pointer variable. An asterisk “*” is also referred as indirection operator is used to dereferences the pointer.
Adding a value to a pointer variable:
When a pointer variable is added, it is similar to adding number of time the size of the pointer variable that is stored.
Example:
//declaring a pointer variable
int *a;
//incrementing the pointer value by 1
a++;
In the above snippet the pointer variable is incremented by “1” means, the size of the pointer variable is being increased in terms of their size.
1 * 2 = 2
Therefore, additional of 2 bytes will be added to the pointer variable “a” after incrementing it by one.
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Starting Out With C++: Early Objects (10th Edition)
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr