Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Mark the following statements is true or false. a. In C++, pointer is a reser

ID: 3680852 • Letter: 1

Question

1. Mark the following statements is true or false.

a. In C++, pointer is a reserved word.
b. In C++, pointer variables are declared using the word pointer.
c. The statement delete p; deallocates the variable p.
d. The statement delete p; the allocates the dynamic variable that is pointed to by p.
e. The address of operator returns the address and value of its operand.
f. If p is a pointer variable, then the statement p = p * 2; is valid in C++.

2. Explain how the operator * is used to work with pointers.
3. Consider the following statement and answer why this statement could lead to what type of misinterpretation?

Int* p, q;

4. Suppose that you have the declaration int * numPtr; what is the difference between the expression: *numPtr and &numPtr?
5. giving the following statements, write C++ statements that use the variable mom numPtr to increment the value of the variable num:

Int num;
Int * numPtr;

6. What does the operator new do?
7. What does the operator delete do?
8. Explain the difference between a shallow copy in a deep copy of data.
9. What is the purpose of a copy constructor?
10. Name two situations in which a copy constructor executes.

Assignment Requirements:

After completing your research for each question, use a Word document that includes each question number along with its response. Use a Word table with two columns, question # and your response (see table below).

Question # Researched Response

Explanation / Answer

operator * gives us the value of a variable at a specified address. For example:
int i = 10;
int *x=&i;
int *y;
or

int *p[5]
declares an array of five pointers to integer variables.

In a shallow copy of data, two or more pointers points to the same memory space.
In a deep copy of data, each pointer has its own copy of the data.

The copy constructor makes a copy of the actual parameter data.

1. When an object is declared and initialized by
using the value of another object
2. When, as a parameter, an object is passed by
value
3. When the return value of a function is an
object

Question # Response 1 (a) False 1(b) False 1(c) False 1(d) False 1(e) False 1(f) False 2

operator * gives us the value of a variable at a specified address. For example:
int i = 10;
int *x=&i;
int *y;
or

int *p[5]
declares an array of five pointers to integer variables.

3 In the given statement, q should be a pointer, but it's not. It is a confusing and misleading formatting style that makes it look like the '*' extends to "q" 4 The & operator gives us the address of a variable and * gives us the value of a variable at a specified address.
  • numPtr is the identifier/name. You declare it by int *numPtr
  • *numPtr is the pointer to your variable
  • &numPtr gives you the address of numPtr
5 Int num;
Int *numPtr;
numPtr = #
num++ 6 Operator new is used to allocate memory for a C++ class object, the object's constructor is called after the memory is allocated. 7 Delete operator deallocate the memory allocated with the new operator. 8

In a shallow copy of data, two or more pointers points to the same memory space.
In a deep copy of data, each pointer has its own copy of the data.

9

The copy constructor makes a copy of the actual parameter data.

10

1. When an object is declared and initialized by
using the value of another object
2. When, as a parameter, an object is passed by
value
3. When the return value of a function is an
object