[C++-sig] Re: MSVC and exposing virtual member functions
Nikolay Mladenov
nickm at sitius.com
Wed Apr 21 16:46:49 CEST 2004
You need to specify public inheritance:
class BaseWrap : public Base
Xavier wrote:
>
> I know similar problems have been covered before, but I couldn't find
> anything about the error I'm getting. I've been wading around the
> documentation for a while and find myself going in circles :S
>
> I compiled boost 1.31 using VC6, with the appropriate fix in inheritance.hpp
>
> I've attached the code I'm trying to get to compile, the error I'm
> getting is:
>
> inheritance.hpp(100) : error C2243: 'type cast' : conversion from 'class
> BaseWrap *' to 'class Base *' exists, but is inaccessible
>
> I pretty much copied the code from the tutorial. Could the part I
> commented out during the boost compile be causing this error?
>
> On a slightly unrelated note, I downloaded the MSVC 2003 Toolkit from MS
> with the 7.1 compiler - Can I just copy the files in there over the top
> of my VC6 files, or do I need to do any extra setup?
>
> Also, as a MSVC project, should I be compiling this sort of thing as a DLL?
>
> - Xavier
>
> ------------------------------------------------------------------------
> #include <boost/python.hpp>
> using namespace boost::python;
>
> class Base {
> public:
> virtual int f() = 0;
> };
>
> int call_f(Base& b) { return b.f(); }
>
> class BaseWrap : Base
> {
> BaseWrap(PyObject* self_) : self(self_) {}
> int f() { return call_method<int>(self, "f"); }
> PyObject* self;
> };
>
> BOOST_PYTHON_MODULE(test_module)
> {
> class_<Base, BaseWrap, boost::noncopyable>("Base", no_init)
> ;
> def("call_f", call_f);
> }
>
> ------------------------------------------------------------------------
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
--
Nikolay Mladenov
Sitius Automation Inc.
www.sitius.com
More information about the Cplusplus-sig
mailing list