Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Invoking base constructor (http://www.velocityreviews.com/forums/t560608-invoking-base-constructor.html)

Lilith 12-12-2007 09:47 PM

Invoking base constructor
 
I need to know if I'm doing something wrong here.

I'm working with a library called SFML, an API for presenting
graphics. I'm trying to inherit from a class called Image in order to
make the class an is-a rather than a has-a entity.

Here's the code, slightly stripped down to show just the constructor.

#include "SFML\Graphics.hpp"

class Grid : public sf::Image
{
public:


Grid (int w, int h, sf::Color c) : sf::Image(w, h, c)
{
return;
}

};

When the parent construct is invoked I get the following unhandled
exception:

Unhandled exception at 0x0000000f in MakeRoads.exe: 0xC0000005: Access
violation reading location 0x0000000f.

If I remove the invocation of the parent constructor I still get an
error but it comes later when I try to plot a point that's outside the
image size (0 x 0 by default) because the image didn't get initialized
by the parent constructor.

Anyone see the error of my approach?

--
Thanks,
Lilith

Victor Bazarov 12-12-2007 09:57 PM

Re: Invoking base constructor
 
Lilith wrote:
> I need to know if I'm doing something wrong here.
>
> I'm working with a library called SFML, an API for presenting
> graphics. I'm trying to inherit from a class called Image in order to
> make the class an is-a rather than a has-a entity.
>
> Here's the code, slightly stripped down to show just the constructor.
>
> #include "SFML\Graphics.hpp"


#include "SFML/Graphics.hpp"

>
> class Grid : public sf::Image
> {
> public:
>
>
> Grid (int w, int h, sf::Color c) : sf::Image(w, h, c)
> {
> return;
> }
>
> };
>
> When the parent construct is invoked I get the following unhandled
> exception:
>
> Unhandled exception at 0x0000000f in MakeRoads.exe: 0xC0000005: Access
> violation reading location 0x0000000f.
>
> If I remove the invocation of the parent constructor I still get an
> error but it comes later when I try to plot a point that's outside the
> image size (0 x 0 by default) because the image didn't get initialized
> by the parent constructor.
>
> Anyone see the error of my approach?


No. The error must be elsewhere.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask




All times are GMT. The time now is 06:02 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.