Read/Write protected memory?

Posted by PenguinBoy on Stack Overflow See other posts from Stack Overflow or by PenguinBoy
Published on 2010-03-20T04:10:40Z Indexed on 2010/03/20 4:11 UTC
Read the original article Hit count: 316

Filed under:
|
|

I'm trying to learn C++ currently, but I'm having issues with the code below.

class Vector2
{
public:
    double X;
    double Y;

    Vector2(double X, double Y)
    {
        this->X = X;
        this->Y = Y;
    };

    SDL_Rect * getSdlOffset()
    {
        SDL_Rect * offset = new SDL_Rect();
        offset->x = this->X;
        offset->y = this->Y;
        return offset;
    };
};

Visual studio throws throw the following error when calling getSdlOffset()

An unhandled exception of type 'System.AccessViolationException' occurred in crossEchoTest.exe

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

I've got a C#/java background, and I'm lost... Any help would be much appreciated.

© Stack Overflow or respective owner

Related posts about c++

Related posts about memory