Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - LifePhilPsyPro

Pages: [1]
1
General / Re: Deleting objects
« on: July 18, 2013, 03:40:29 pm »
I hear what you are saying. Thanks!
Ill try and fix that,and hopefully will learn RAII asap :)

2
General / Re: Deleting objects
« on: July 18, 2013, 03:23:24 pm »
Thanks guys for the quick reply.
Well i do check,to make sure i am not deleting twice.
Quote
      int DeadAlive = Dragon->TestIfDead();
      MonPtr = Tail;
      if(DeadAlive == true)
      {
         if(Tail == Dragon){
            MonPtr = Dragon;
            Dragon = Dragon->Node;
            free(MonPtr);
            delete MonPtr;
         }
         else if(Dragon->Node == NULL){
            MonPtr = Dragon;
            Dragon = Tail;
            free(MonPtr);
            delete MonPtr;
         }
         else{
            for(short NDC = 0; NDC < DC; NDC++){
               MonPtr = MonPtr->Node;
               if(NDC + 1 == DC){
                  Dragon = MonPtr;
                  Dragon->Node = Dragon->Node->Node;
               }
            }
            free(MonPtr);
            delete MonPtr;
         }
      }

Here is a part of the code. THe one that is crashing...
Dragon is an object. Well,actualy its a linked list. Tail is obviously the pointer to the first Object of the linked list and MonPtr is just a ptr that is used to delete dead dragons.
So as you see i check if the monster is dead,if it is i try to delete it.
So as much as i can tell i am not deleting twice. Is there something i am missing? :)


3
General / Deleting objects
« on: July 18, 2013, 02:48:28 pm »
Why is it that i cant delete any objects in the
Quote
while (window.isOpen())
loop?
Whenever i try to delete an object. Now matter what the object is or how it is defined the Program just crashes with an error of
Quote
_BLOCK_TYPE_IS_VALID (pHead->nBlockUse)
.
The loop might be fully empty (except the delete function) and it will crash anyways.
Thanks in advance.

Pages: [1]