Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,005 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,369 people online right now. Registration is fast and FREE... Join Now!




delete array[i]

 
Reply to this topicStart new topic

delete array[i]

TheMagnitude
31 Mar, 2008 - 11:05 AM
Post #1

D.I.C Head
Group Icon

Joined: 12 Jan, 2008
Posts: 88


Dream Kudos: 125
My Contributions
If I had an array of anything:

array[6];

what would be the effect of:

delete array[2];

Cause Im gettin some strange problems, does it mean that I can't use array[2] anymore and need to re initiate it somehow?
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Delete Array[i]
31 Mar, 2008 - 11:59 AM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,226



Thanked: 37 times
Dream Kudos: 25
My Contributions
The delete command is meant to be used in conjunction with the new operator - generally for dynamic memory allocation. what is it you are trying to do?

http://www.cplusplus.com/doc/tutorial/dynamic.html
User is offlineProfile CardPM
+Quote Post

TheMagnitude
RE: Delete Array[i]
31 Mar, 2008 - 12:50 PM
Post #3

D.I.C Head
Group Icon

Joined: 12 Jan, 2008
Posts: 88


Dream Kudos: 125
My Contributions
i have a class: instance which has a member *instances[128];

does that mean that I cannot use delete on it?

what would the affect be if:

lala = new int[5];
delete *(lala+2);

or i used delete lala[2];
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 12:42PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month