We discussed the distinction between two areas of memory: the heap and the run-time stack. Suppose that variable p has type int*. Which of the following is a correct C++ statement or statement sequence that makes p point to newly allocated memory in the heap?
Suppose that p is defined to point to memory as in the preceding question. Which of the following stores 25 in the integer variable to which p points.
Suppose that a C++ program contains the following statements.
int* p; p[0] = 1;Which of the following is a true statement about what happens?
In a C++ program, x[y] abbreviates
C++ notation p->x abbreviates
Suppose that the following structure type definition is given.
struct Gadget
{
int puff;
int stuff;
Gadget(int p, int s)
{
puff = p;
stuff = s;
}
};
Which of the following will create a Gadget called g, stored
in the run-time stack, whose puff
variable contains 4 and whose stuff variable contains 8?
If g is the Gadget created in the preceding question, which of the following will print the value of the stuff variable in Gadget g on the standard output?
Using type Gadget from the previous question, which of the following will create a new Gadget in the heap, with its puff variable holding 39, and its stuff variable holding 4, and make variable w point to the new Gadget?