[C++-sig] Passing inherited classes back to C++

Tom Brooks tgbrooks at gmail.com
Sun May 6 11:12:43 CEST 2007


I run this python code:

quad = Renderer.Quad(250, 250, 64,64)
c = Renderer.Color()
Renderer.AddRenderable(quad) #Removing this line makes it not crash

AddRenderable does:
renderables.push_back(renderable);

And later that frame, this is done:
    for(std::list<Renderable*>::iterator itr = renderables.begin(); itr !=
renderables.end(); itr++)
    {
        Renderable* renderable = *itr;
        renderable->Draw(); //It crashes here! With error "R6025: pure
virtual function call".
    }

I use your Py++ code (only thing changed is it's namespace, which is now
Renderer), along with:

    def("AddRenderable",&AddRenderable);

in the Renderer namespace.

My C++ code runs just fine if I don't use anything from Python.

There, I think that's complete.

On 5/6/07, Roman Yakovenko <roman.yakovenko at gmail.com> wrote:
>
> On 5/5/07, Tom Brooks <tgbrooks at gmail.com> wrote:
> > Thank you for the fast reply. I would have tried Py++ myself, but I'm
> unable
> > to install it. I get an error that the .NET framework SDK must be
> installed
> > in order to build Python extensions when I try to install GCC_XML. I
> tried
> > to download and install the .NET SDK, but I'm sure if I've really got
> all of
> > it. I didn't select much for the installation process. Though it is
> > off-topic, any help with this would be nice too. I use Visual Studios
> C++
> > express on Windows XP. I have Python 2.4 and the Windows Platform SDK.
> >
> > As for the code, I haven't looked at it in a lot of detail yet, but a
> simple
> > copy-and-paste gives me a run-time error that I'm calling a pure-virtual
> > function when I call Draw() from the passed in Renderable*. Any more
> > thoughts?
>
> Please provide a complete example
>
> --
> Roman Yakovenko
> C++ Python language binding
> http://www.language-binding.net/
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070506/35206635/attachment.htm>


More information about the Cplusplus-sig mailing list