[C++-sig] Multiple Constructors

troy d. straszheim troy at resophonic.com
Mon Aug 18 17:14:30 CEST 2008


Bilokon, Paul wrote:
> Hi,
> 
> I'm wondering if there is an example that demonstrates how one should
> deal with classes with multiple constructors with different signatures,
> e.g.

There is.  It is right in the docs.

class_<World>("World", init<std::string>())
     .def(init<double, double>())
     .def("greet", &World::greet)
     .def("set", &World::set)
;

>     scope in_Term = class_<Term>("Term", init<>())
>         .def(init<const Term::Foo, Bar>())
>         .def(init<const Term::Foo, Bar, bool>())
>         .def(init<const std::string &>())
> 
> I don't think this approach is valid.

You're going to have to be more specific than that.

-t





More information about the Cplusplus-sig mailing list