Question: C++ Given the following code: int *x = new int; (b) new returns an int (r) new returns the address of space for an int
C++
Given the following code: int *x = new int;
(b) new returns an int
(r) new returns the address of space for an int on the stack
(e) new returns the address of space set aside on the heap foran int
(l) Only 2 of the above
(n) all of the above (not including the answer Only 2 of tehabove)
Other:
Delete:
(a) Removes variables from the stack
(r) Removes variables from the heap
(t) Frees memory for future variables
(m) Can be used on variables other than those that have beennew-ed
(n) Only 2 of the above
(i) 3 of the above (not including the answer Only 2 of theabove)
(e) All of the above
Given the following code:
player *x;
cout << x << endl;
What is printed out?
(t) 0x62ff08
(s) 0xffffff
(o) 0x62ffcc
(r) 0x62fe4b
(c) Don't know what x holds
(a) Other
Given the following code:
int arr[4] = [3,1,4,2]
To access the 3rd value [i.e. 4] you'd use
(d) &arr[2];
(y) *arr[2];
(r) arr[2];
(v) Only 2 of the above
(g) All of the above (well,not including the answer Only 2 ofthe above...)
You’d want to dynamically allocate (aka new) an arrayif:
(h)You didn’t know its size at compile time
(e) You wanted it to outlive its natural scope
(o) You want more than one variable to point to the samearray
(a) Only 2 of the above
(y) All of the above (not including the answer Only 2 of theabove)
(p) Other
Given the following code,
int *arr = new int[4];
To place 4 in the 3rd space in the array, you'd use:
(r) &arr[2]=4;
(p) arr[2]=4;
(e) *arr[2]=4;
(s) Only 2 of the above
(o) All of the above (not including the answer Only 2 of theabove)
Other:
The following code:
int **x = NULL;
x = new int *[4];
(s) Creates a pointer to an array of 4 ints
(t) Creates a pointer to an array of 4 addresses
(b) Creates a pointer to an array of 4 NULL values
(l) Is bad code!
(m) Only 2 of the above
(u) Only 3 of the above (not including the answer Only 2 of theabove)
(w) Other
Step by Step Solution
3.44 Rating (163 Votes )
There are 3 Steps involved in it
This is the solution of this question let start solve each question one by one Lets go through each ... View full answer
Get step-by-step solutions from verified subject matter experts
