Fresh features from the #1 AI-enhanced learning platform.Try it free
Fresh features from the #1 AI-enhanced learning platformCrush your year with the magic of personalized studying.Try it free
Question

The __________ operator is used to dynamically allocate memory.

Solutions

Verified
Answered 2 months ago
Step 1
1 of 2

To allocate memory space dynamically we use the new operator with the following syntax,

/*
// allocate single variable
ptrName = new ptrDataType;
//allocate array of variables
ptrName = new ptrDataType[numberOfItems];
*/
// example
int  *iPtr = new int[10];
char *cPtr = new char;

NOTE : when you try to use use new to allocate a space which is not available , an exception is thrown to indicate that error.

Create an account to view solutions

Create an account to view solutions

Recommended textbook solutions

Computer Science 1st Edition by Kevin Wayne, Robert Sedgewick

Computer Science

1st EditionISBN: 9780134076485 (2 more)Kevin Wayne, Robert Sedgewick
Starting Out with C++: Early Objects 7th Edition by Godfrey Muganda, Judy Walters, Tony Gaddis

Starting Out with C++: Early Objects

7th EditionISBN: 9780136077749 (2 more)Godfrey Muganda, Judy Walters, Tony Gaddis
874 solutions
A Guide to SQL 9th Edition by Mary Last, Philip J Pratt

A Guide to SQL

9th EditionISBN: 9781111527273Mary Last, Philip J Pratt
Starting out with Visual C#, Global Edition 4th Edition by Tony Gaddis

Starting out with Visual C#, Global Edition

4th EditionISBN: 9781292163215Tony Gaddis
851 solutions

More related questions

1/4

1/7