Question
c++ 1. Which of the following are true about the delete keyword? a. To prevent memory leaks, every 'new' usage should be cleaned up with
c++ 1. Which of the following are true about the delete keyword?
a. To prevent memory leaks, every 'new' usage should be cleaned up with a 'delete' usage
b. None of these are true
c. Arrays can be deleted using the 'delete {...}' syntax}
d. There is no delete keyword
e. You need to call delete every time you statically allocate memory.
2. What is wrong with the following code?a. There is a type mismatch calling "foo"
b. Delete [] is needed to prevent memory leaks since res points to an array of integers
c. New cannot be called inside of a function other than main()
d. Nothing is wrong, the programmer can safely fill in the commented lines with their desired computations
3. Please select the correct way to release the memory at the end.
a. delete p; delete [] c;
b. delete c;
c. delete [] c; delete p; delete a;
d. delete p; delete c;
4. What type of argument passing does this code display?
#includeusing namespace std; void add10 (int num){ num = num + 10; } int main (){ int a = 10; add10(a); cout a. Pass by reference
b. Pass by pointer
c. None of these
d. Pass by value
e. Pass by pointer by reference
include sing namespace std; nt main ()\{ int a=5; int p= new int; int c= new int [5]; // release memory return 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started