Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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?image text in transcribeda. 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.

image text in transcribed

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?

#include  using 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

What payments are included in the lease liability?

Answered: 1 week ago