Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Invoking base constructor

Reply
Thread Tools

Invoking base constructor

 
 
Lilith
Guest
Posts: n/a
 
      12-12-2007
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
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      12-12-2007
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Casting from base to derived class in base constructor pastbin@gmail.com C++ 2 02-07-2008 02:41 PM
Calling base class constructor from derived class Copy constructor ali C++ 4 03-05-2007 09:15 AM
Invoking A Base class constructor hurcan solter C++ 3 01-12-2007 02:35 PM
Invoking templatized base class constructor from templatized derived class constructor mrstephengross C++ 5 05-18-2005 07:12 PM
Invoking a base class constructor Dominique C++ 7 11-17-2003 03:37 PM



Advertisments