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 ResponseExplanation / 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
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.
- 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
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.
The copy constructor makes a copy of the actual parameter data.
101. 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
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.