Windows error 0x000002CE, 718

Detailed Error Information

LOG_HARD_ERROR[1]

MessageApplication popup: %1 : %2
Declared inwinerror.h

This appears to be a raw Win32 error. More information may be available in error 0x800702CE.

HRESULT analysis[2]

This is probably not the correct interpretation of this error. The Win32 error above is more likely to indicate the actual problem.
FlagsSeveritySuccess

This code indicates success, rather than an error. This may not be the correct interpretation of this code, or possibly the program is handling errors incorrectly.

Reserved (R)false
OriginMicrosoft
NTSTATUSfalse
Reserved (X)false
FacilityCode0 (0x000)
NameFACILITY_NULL[2][1]
DescriptionThe default facility code.[2][1]
Error Code718 (0x02ce)

Possible solutions

7

why is deleting this object causing problems?

c++
winapi

You haven't defined virtual destructors for your weapon classes. http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.7

answered on Stack Overflow Nov 24, 2011 by FeatureShock
4

why is deleting this object causing problems?

c++
winapi

You problem is the definition of

class Brain : public Entity
{
private:
    std::vector<Gun*> weapons;

and the ownership of Gun* by Brain object.

Brain::~Brain()
{
    for (unsigned int i = 0; i < weapons.size(); i++)
    {
        delete weapons[i];
    }
}

If a Brain is copy constructed the delete will be called multiple times deleting the same Gun from different weapons vector. And a Brain temporary is created when you add your Agents (Agent being a derived class of Brain) like so in main function.

int main()
{
    Level* level;
std::vector<Agent> agents;

level = new Level(agents);

for (int i = 0; i < 1; i++)
    {
        //TODO - health is a pointless parameter here
        agents.push_back(Agent(100, *level, agents, level->Pickups(), D3DXCOLOR(1.0F, 0.4f, 0.4f, 1.0f)));
    }

delete level;

}

 If you implement a copy constructor for Brain that clones the Gun* vector you should be ok. Alternative you should use shared_ptr<Gun> in your vector so that you don't have to delete them at all.

To summarize your problem boils down to

class Foo{};

class Bar
{
public:
    Bar()
    {
        mFooVec.push_back( new Foo() );
        mFooVec.push_back( new Foo() );
    }

    ~Bar()
    {
        for( unsigned int i = 0;i < mFooVec.size(); ++i )
        {
            delete mFooVec[i];
        }
    }

    std::vector<Foo*> mFooVec;
};

int main()
{
    Bar x;
    Bar y = x;

    return 0;
}

Here both Bar x and y have the same two Foo* in their mFooVec

answered on Stack Overflow Dec 5, 2011 by parapura rajkumar • edited Dec 6, 2011 by parapura rajkumar

Comments

Leave a comment

(plain text only)

Sources

  1. winerror.h from Windows SDK 10.0.14393.0
  2. https://msdn.microsoft.com/en-us/library/cc231198.aspx

User contributions licensed under CC BY-SA 3.0