Invoking base constructor

L

Lilith

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?
 
V

Victor Bazarov

Lilith said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top