|
-
July 1st, 2012, 01:45 AM
#1
Why use delete?
My manager always telling me to use delete []. I don't know why? Can u tell me plz??? Is C is the only langz to usz delete???
Last edited by Steve R Jones; October 1st, 2015 at 05:37 AM.
-
July 1st, 2012, 02:04 AM
#2
Re: Why use delete?
Uh oh, this does not bode well.
 Originally Posted by Yarlini Amirthanesan
My manager always telling me to use delete []. I don't know why? Can u tell me plz?
You should delete[] what you new[], but also read Stroustrup's FAQ on How do I deal with memory leaks?
 Originally Posted by Yarlini Amirthanesan
Is C is the only langz to usz delete?
Your question was for C++, not C. It sounds like you're confused and clueless enough to require re-learning from the ground up. I suggest that you take some time to work through a book like Accelerated C++, starting from the beginning without skipping anything.
-
July 1st, 2012, 02:44 AM
#3
Re: Why use delete?
When buying that book also buy a new keyboard. The one you have seem to have some broken keys...
-
July 1st, 2012, 03:59 AM
#4
Re: Why use delete?
 Originally Posted by Yarlini Amirthanesan
My manager always telling me to use delete []. I don't know why? Can u tell me plz??? Is C is the only langz to usz delete???
Yarlini Amirthanesan
Netw0rk Management | Military Communications
Command, Control, Communzcations & Intelligence Division
Defence Science and Technoogy Organisation
Add: PO Box 1500
Edinburgh, South Australia, 5611
Tel: +61 8 738 97745
Fax: +61 8 738 97549
Email: [email protected]
It's not necessary to post all this personal contact information in every post. I don't think you should refer to your employer publicly unless you represent it officially which I doubt you do here.
Anyway note that new/delete isn't available in C. These are C++ operators.
C++ doesn't have the automatic memory management you find in other modern languages such as Java and C#. This makes C++ more flexible but it also puts an additional burden on the programmer who must make sure everything that's allocated on the heap gets properly deleted.
But there's relief to be had. A first simple step is to consider std::vector as an alternative to ordinary arrays. Then there are all the other containers in the standard library and the so called smart pointers like std::shared_ptr.
Last edited by nuzzle; July 1st, 2012 at 04:05 AM.
-
July 1st, 2012, 08:13 AM
#5
Re: Why use delete?
 Originally Posted by Yarlini Amirthanesan
Can u tell me plz??? Is C is the only langz to usz delete???
Yarlini Amirthanesan
Netw0rk Management | Military Communications
Command, Control, Communzcations & Intelligence Division
Defence Science and Technoogy Organisation
Add: PO Box 1500
Edinburgh, South Australia, 5611
Tel: +61 8 738 97745
Fax: +61 8 738 97549
Email: [email protected]
You're in the communications divisions - seriously? Wow.
-
July 1st, 2012, 09:57 AM
#6
Re: Why use delete?
 Originally Posted by GCDEF
You're in the communications divisions - seriously? Wow.
Honestly, I'd take the post with a pinch of salt. I wouldn't be surprised if the poster's actual intent was simply to make this "Yarlini Amirthanesan" look bad, preferably professionally...
I've never seen anyone online so eager to reveal their real identity and coordinates, unless they are actual professionals representing their company.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
-
July 1st, 2012, 10:00 AM
#7
Re: Why use delete?
 Originally Posted by monarch_dodra
I wouldn't be surprised if the poster's actual intent was simply to make this "Yarlini Amirthanesan" look bad, preferably professionally...
I didn't think of that. Maybe some admin here could drop a note at that email address? Hmm...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|