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?
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...
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?
Is the 2px orbital an eigenfunction of operator Lz? if it is, what is the angular...
Is the 2px orbital an eigenfunction of operator Lz? if it is, what is the angular quantum number m for a 2px orbital? if it isn't what is the average value of operator Lz for the 2px orbital?
What are the consequences to a hotel operator of a customer such as Thomas Cook
What are the consequences to a hotel operator of a customer such as Thomas Cook collapsing into liquidation?  How does it affect resigning contracts with new owners? 
Explain the difference between the modulo operator and the division operator for C#
Explain the difference between the modulo operator and the division operator for C#
When it comes to dynamic memory allocation and delete[] pointer, what does it mean to say...
When it comes to dynamic memory allocation and delete[] pointer, what does it mean to say that, CRT detected that the application wrote to memory after end of heap buffer? I tried to duplicate the error by deleting the pointer address twice and it didn't produce the same error code so that's not it. What might cause this problem?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT