2

Following is the my C++ class

namespace X {
  class ChildFactory: public Father {
  public:
    static ChildFactor* createChildFactory(const properties* ptr = NULLPTR);
  private :
    // no instances allowed
    ChildFactory();
    ChildFactory(const properties* ptr);
    ~ChildFactory();
  };
}; 

following is how I have defined the Boost::Python constructs.

BOOST_PYTHON_MODULE(TestPy) 
{
  boost::python::class_<X::ChildFactory, boost::noncopyable>("ChildFactory")
    .def("createChildFactory", &X::ChildFactory::createChildFactory,  boost::python::return_value_policy<boost::python::manage_new_object>() )
    .staticmethod("createChildFactory")
  ;
}

But it is giving me weird compiler template error.

Error is

destructor could not be generated because a base class destructor is inaccessible

3 Answers 3

1

Try exposing your class as having no_init:

class_<Foo, boost::noncopyable>("Foo", no_init);
Sign up to request clarification or add additional context in comments.

Comments

0

destructor could not be generated because a base class destructor is inaccessible

So did you solve it?

If not, what that means it is you declared your constructor function in the private section of the class, thats why it can not be accessed. In fact you can not instantiate that class, it can only be used as a singleton.

Move your

ChildFactory();
~ChildFactory();

to the public section and lets us know.

Comments

0

manage_new_object might use auto_ptr<> which requires delete pointer_to_ChildFactory to work which needs access to ~ChildFactory().

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.