Invoking base constructor



 DEVELOP > c-Plus-Plus > Invoking base constructor

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Lilith"
Date: 12 Dec 2007 03:47:47 PM
Object: 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
.

User: "Victor Bazarov"

Title: Re: Invoking base constructor 12 Dec 2007 03:57:25 PM
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
.


  Page 1 of 1

1

 


Related Articles
Invoking a base class constructor
Invoking A Base class constructor
Invoking templatized base class constructor from templatized derived class constructor
parameter passing to base class constructor (definition and delcaration)
Call base class constructor?
Why is the Base class Constructor getting called twice
Passing derived classes uninitialized variable to base class constructor !!
Copy constructor for a class that contains a pointer to a base class type (newbie)
Static Method in base class accessing protected constructor of derived clas
Can pure virtual function be called in base class constructor?
Copy constructor for a class that contains a pointer to a base classtype (newbie)
virtual base classes and constructor calls
"Virtual constructor" abstract base class - feasibility?
copy constructor: initialize the base
Automatic conversion to base class when calling constructor.
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER