Can you post the contents of Body.h |
|
Been a long long time since I've written anything in C++, I'm getting back into it. I need a little help, because I don't understand the errors |
|
Can you post the contents of Body.h |
|
(\_ _/)
(='.'=)
(")_(")
Bien Sur |
|
Ok, |
|
(\_ _/)
(='.'=)
(")_(")
Either that, |
|
(\_ _/)
(='.'=)
(")_(")
Ooooh. Damn university taught me java, is there ever a more useless language? Is there a good C++ book like 'C in a nutshell'? |
|
Last edited by ninja9578; 05-09-2008 at 01:05 AM.
Bjarne Stroustrup (the guy who developed C++) has written a few books |
|
(\_ _/)
(='.'=)
(")_(")
If you've gone the dynamic way, remember to free objects after you've finished with them |
|
Last edited by Ynot; 05-09-2008 at 01:19 AM.
(\_ _/)
(='.'=)
(")_(")
Oh right, I have to write a destructor. Damn java's garbage collector made me loose everything that I knew about C++. |
|
Last edited by ninja9578; 05-09-2008 at 03:09 AM.
Remember to make those destructors virtual as well, if you've got an inheritance hierarchy going on anywhere. |
|
Truths are material, like vegetables and weeds; as to whether vegetable or weed, the decision lies in me.
--Max Stirner
Oh crap, I didn't think that through. I have a parent class with some stuff in it, which needs to be purged on calling the destructor, but what happens if I call the destructor for the child class? Will it run both? |
|
The child class' destructor implicitly calls the parent's destructor automatically when invoked, when the "parent" part of the object is deallocated. |
|
Last edited by MrDoom; 05-09-2008 at 08:19 AM. Reason: example code and stuff about handling deletion
Truths are material, like vegetables and weeds; as to whether vegetable or weed, the decision lies in me.
--Max Stirner
If you got stuck figuring out this compile error, I highly recommend boost::shared_ptr, lest your application leak like an old lady with bladder problems |
|
I've never really understood people who say this |
|
Last edited by Ynot; 05-09-2008 at 05:49 PM.
(\_ _/)
(='.'=)
(")_(")
Once I get used to C++ I doubt that my program will leak, I'm used to using C |
|
That's why it's prone to leaking, it requires foresight and sometimes we make a devastating blunder. We've all had at least one of those embarassing "missing semicolon" errors that completely breaks the code and we spend hours looking for it, only to notice it after we give up in frustration and come back the next day (or week |
|
Truths are material, like vegetables and weeds; as to whether vegetable or weed, the decision lies in me.
--Max Stirner
I use XCode, there is a picture of it in my first post |
|
Last edited by ninja9578; 05-09-2008 at 09:36 PM.
Good intentions are never enough, and of all the bugs out there, memory leaks are usually among the toughest to track down. It's usually not as simple as making sure the news and deletes lign up. Stuff gets passed around, ownership gets transfered, things get double-deleted, assumptions are not met, and things throw exceptions and wind the stack. |
|
I know that the Apple IDE does memory leak checking, doesn't .NET? .NET is just as powerful if not more so. |
|
That only works on the same pointer, ie: |
|
Last edited by RedfishBluefish; 05-10-2008 at 09:19 AM.
Remember: pointing to "nothing" (i.e. 0) is not the same as pointing to an empty memory address which has been deallocated. |
|
Truths are material, like vegetables and weeds; as to whether vegetable or weed, the decision lies in me.
--Max Stirner
Well, technically, after you delete something, the memory becomes available to the OS to have its way with it. So double deleting can have some of the following effects (and then some): |
|
Bookmarks