Write your answers to the following questions in a flat text file
hwkPointers.txt (not a Word document nor a Rich Text Format file):
- Pointer Syntax:
- Write the declaration of a double pointer named average
- Write the declaration of a double pointer named aver and assign nullptr to it
- What is the difference between a. and b.?
- Dynamically allocate memory for a DNA object and store its address in a variable named dnaPtr
- Declare a one-dimensional array of 7 doubles (on the stack) named rainfall
- Declare and allocate memory (on the heap) for a one-dimensional array of 1024 doubles named prices
- Declare a two-dimensional array of doubles (on the stack) named tickerValues with 12 rows and 31 columns
- Declare and allocate memory (on the heap) for a two-dimensional array of strings named carMakes with 6 rows, each with 20 columns
- Give the declaration for a function assignPicture() that takes a pointer to a HugeStudentRecord object
- Give the declaration for a function calculateAverage() that takes an array of doubles and an int named count
- Write a call to calculateAverage(), passing it rainfall
- Write the implementation for doubleAmount() so that all of the following code executes and prints out just 14:
int num = 7;
doubleAmount( &num);
std::cout << num;
- Using just two words, describe what is wrong with the following code:
CoolObject* p = new CoolObject;
p->printInfo();
p = new CoolObject;
p->printInfo();
-
For the three variable declarations below, for each one state if their contents are on the stack, on the heap or both?
- int counter = 0;
- string errorMsg = "";
- string* result = new string();
Submission
Submit your txt file at
https://3110.cs.mtsu.edu/. For further instructions, please see the
Miscellaneous page.
Rubric:
Points Item
---------- --------------------------------------------------------------
_____ / 11 1
_____ / 3 2
_____ / 1 3
_____ / 1 4
_____ / 16 Total
Last Modified: