answersLogoWhite

0

New creates objects. Delete deletes objects. eg - int *x = new int; // Give me a new int eg - delete x; // Delete the int that was created These functions are useful because they allow you to allocate as much memory as you need (eg ask the user for how many numbers do they want to type in, allocate that many ints and then loop through and store the values). Note that there are two other operators, new[] and delete[] that are used for creating/deleting arrays. eg - int *x = new int[5]; // Give me 5 new ints eg - delete[] x; // Delete the 5 ints If you mix and match the different operators(eg new[] with delete) you may end up with memory leaks - delete only expects one object, so if you give it 10 objects created by new[] then it will only delete one.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

What is difference between sky plus and sky plus a grade?

A Grade sky plus is a reconditioned/repaired box........ .....Sky plus is a brand new box.


What is the difference between Casio Fx 570Es and Casio Fx 570Es Plus?

PLUS has two extra New functions.... Random integer New Equation mode


Add two numbers in pointer in using c plus plus?

int* a = new int(40); int* b = new int(2); int x = *a + *b; // x = 42 delete b; delete a;


What are new and delete operators in c plus plus?

New and Delete are the memory management operators in c++,like c language we use malloc() and calloc() functions to allocate memory and free() functiong to release the memory similarily we use new to allocate memory in C++ and Delete to release the allocated memory....


Are new and delete operators in c plus plus related to flush?

The new and delete operators in C++ are not related to flush. New is used to allocate memory, while delete is used to deallocate memory. Flush is a library concept that allows you to ensure that IO is completed, and not buffered, before proceeding to the next step.


Program for new and delete operator using c plus plus?

#include<iostream> struct object { int m_data; }; void main() { object obj=new object; obj.m_data = 42; delete( obj ); return( 0 ); }


What is the difference between incidence and prevalence?

Incidence is number of new cases diagnosed prevalence is the the burden of disease that is new cases plus old cases


Why use new and delete operator overloading in c plus plus?

one reason to use new and delete operator overloading in c++ is when you are using your own memory manager code. when the user of your code calls the new keywork, your memory manager code can allocate memory.


Write c plus plus program for new and delete operator using class?

#include<iostream> class foo{ int m_data; }; int main() { foo* p=new foo; delete( foo), foo=NULL; return(0); }


What is the difference between the mid Atlantic and the new England region?

whats the difference between midAtlantic and new England


What is the difference between traditional banking and modern banking?

difference between modern and traditional banking is


What is the difference between the old broadsheet and the new broadsheet?

The difference is that one of them is old and the other one new.