Question

In: Computer Science

(a) What is a pointer? (b) What is a dereferencing operator?


 (a)

 What is a pointer?

 (b) What is a dereferencing operator?

 (c)

 What is the difference between assignment statements p1 = p2; and *p1 = *p2;

 (d) What is a dynamic variable?

 (e)

 What is the purpose of the new operator?

 (f)

 What is the purpose of the delete operator?

 (g)

 What is the freestore (also called the heap)?

 (h)

 What is the difference between dynamic variables and automatic variables?


Solutions

Expert Solution

(a)   A pointer is an object that stores the memory address of another object.
(b)   Dereference operator is an operator which returns the value at the address which is pointed by the pointer. Dereference operator is *.
(c)   In p1 = p2, the value of p2 is getting assigned to p1, in *p1 = *p2, the dereferenced value of p2 is getting assigned to dereferenced values of p1, the second one deals with pointer objects.
(d)   The dynamic variable is a variable whose address is determined when the program is run.
(e) The new operator is used to dynamically allocate the memory for pointer objects.
(f)   delete operator is used to free the memory allocated by the new operator.
(g)   freestore is an area of memory that is used for dynamic allocation of memory while the program is running.
(h)   the dynamic variable is the variables which get its memory by the explicit call, while auto variable gets their memory assigned by the compiler automatically.


Related Solutions

C++ please. Define a problem with user input, user output, Pointer, with const and sizeof operator.
C++ please. Define a problem with user input, user output, Pointer, with const and sizeof operator.
1.) What type of data is stored in a pointer? a. an integer b. a character...
1.) What type of data is stored in a pointer? a. an integer b. a character c. A memory address d. None of the above 2.) A stack in used to implement method calls in a program. True or Flase?
How do you dereference a pointer? Explain the difference between a dereferenced pointer and the pointer...
How do you dereference a pointer? Explain the difference between a dereferenced pointer and the pointer itself.
If pointer 1 is spun and then pointer 2 is ​spun, determine the probability of the...
If pointer 1 is spun and then pointer 2 is ​spun, determine the probability of the pointers landing on a color other than yellow on the first spin and a color other than red on the second spin. Pointer 1      Pointer 2 pointer 1 has 2 sections 50% red and 50% yellow.. pointer 2 has 3 sections 50% blue and 25% red and 25% yellow
Consider a disk with block size B = 512 bytes. A block pointer is P =...
Consider a disk with block size B = 512 bytes. A block pointer is P = 6 bytes long, and a record pointer is PR = 7 bytes long. A file has r = 30,000 EMPLOYEE records of fixed length. Each record has the following fields: Name (30 bytes),Ssn (9 bytes), Department_code (9 bytes), Address (40 bytes), Phone (10 bytes), Birth_date (8 bytes), Sex (1 byte), Job_code (4 bytes), and Salary (4 bytes, real number). An additional byte is used...
8.20 Person Pointer Function Make a function that will accept a pointer to a vector of...
8.20 Person Pointer Function Make a function that will accept a pointer to a vector of Person pointers as a parameter. Return a pointer to the Person with the highest salary. The function must be signatured like: Person* getBestPaid(vector*); The class definition is: class Person { public: double salary; string name; }; You may include code in your main() to test, but the tests in this assignment will ensure your code is correct. You may assume there will ways be...
A. What can happen if pointer is uninitialized. Explain the concept and what should ideally be...
A. What can happen if pointer is uninitialized. Explain the concept and what should ideally be done in such case B. Memory was allocated initially for 5 elements, later on two more elements added to list. How can space be managed in such case. Implement the scenario in C.
Apply ?̂2 and ?̂?operator on the following wavefunctions, a. ( 3 4? ) 1/2 ???? b....
Apply ?̂2 and ?̂?operator on the following wavefunctions, a. ( 3 4? ) 1/2 ???? b. ( 3 8? ) 1/2 ???? ? ?? c. ( 3 8? ) 1/2 ???? ? −?? What is the result? Which is these functions are eigen functions of both operators? Is there anything else you like to conclude?
Send an element from 2d array to a function using pointer to pointer. c++ I am...
Send an element from 2d array to a function using pointer to pointer. c++ I am having an issue with being able to send specific elements to the swap function. #include <iostream> using namespace std; void swap(int **a, int **b){    int temp = **a;    **a=**b;    **b=temp; } void selSort(int **arr, int d){    for(int i =0; i<d-1; i++){        int min = *(*arr+i);        int minin = i;        for(int j =i+1; j<d; j++){...
Code should be written in C Use pointer variables for parameter passing, where appropriate and pointer...
Code should be written in C Use pointer variables for parameter passing, where appropriate and pointer arithmetic when working with arrays. 1) Using initialization lists, create 5 one-dimensional arrays, one for each of these: hold the names of the people running in the election hold the names of the subdivision hold the vote counts in the Brampton subdivision for each candidate hold the vote counts in the Pickering subdivision for each candidate hold the vote counts in the Markham subdivision...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT