Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
deleting an array of objects
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
mickey22
New Member
Join Date:
Feb 2007
Posts:
105
#1
deleting an array of objects
Sep 3 '08, 09:36 PM
Could you please give an example how to create and an array of objects and how to delete them ?
Do I have to create for loop to delete all of them?
weaknessforcats
Recognized Expert
Expert
Join Date:
Mar 2007
Posts:
9214
#2
Sep 3 '08, 09:47 PM
Err... the book says:
[code=cpp]
MyClass* array = new MyClass[100];
[/code]
That creates the array. So:
[code=cpp]
delete [] array;
[/code]
should delete the array.
Constructors and destructors will be called as needed.
Since this is an array, you cannot delete specific members. If you have that kind of requirement, use the vector container.
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment