Discover answers to your questions with Westonci.ca, the leading Q&A platform that connects you with knowledgeable experts. Get accurate and detailed answers to your questions from a dedicated community of experts on our Q&A platform. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.
Sagot :
A specific place in memory is assigned to a variable when it is declared so that it can store a value. Special variables called pointers are used to store double value to other variables' memory addresses.
What are Pointers?
In C++, a pointer is a variable that holds the address (or location in memory) of another variable. In other words, a pointer directs the user to the location of a different variable. Pointers in C++ have data types just like ordinary variables do. The data type of the a pointer and the variable it points to should match.
We specify the data type of pointers so that we can determine how many bytes of data the variable it contains the address of uses. When we increase (decrease) the value of a pointer, By the size of the data type it points to, the pointer is increased (or decreased).
How to use Pointers in C++?
To use pointers in C++, we must take the following actions:
Make a pointer variable first. Use the & operator to provide the pointer the address of another variable. Use the operator to access the value at the address.
main ()
{
Var = 10;
// Pointer level-1
Integer* ptr1;
// Pointer level-2
ptr2;
// Pointer level-3
ptr3;
// Storing address of variable Var
// to pointer variable ptr1
ptr1 = &Var;
// Storing address of pointer variable
ptr2 = &ptr1;
// Storing address of level-2 pointer
ptr3 = &ptr2;
// Displaying values
print ("Value of variable "
"Var = %d\n",
Var);
print("Value of variable Var using"
" Pointer ptr1 = %d\n",
*ptr1);
print("Value of variable Var using"
" Pointer ptr2 = %d\n",
**ptr2);
print("Value of variable Var using"
" Pointer ptr3 = %d\n",
***ptr3);
return 0;
}
To know more about pointer to double visit:
https://brainly.com/question/14299488
#SPJ4
We appreciate your visit. Our platform is always here to offer accurate and reliable answers. Return anytime. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Westonci.ca is committed to providing accurate answers. Come back soon for more trustworthy information.