[C++-sig] Member function of other class
Trigve Siver
trigves at yahoo.com
Fri Aug 17 14:58:34 CEST 2012
Hi,
I'm curios, why this piece of code does compile?
struct BaseClass
{ void func() {}
}; struct Wrap
{ void func() {}
}; BOOST_PYTHON_MODULE(main)
{ class_<BaseClass>("Base", no_init) .def("func", &Wrap::func) ;
}
I'm asking because a want to do something like this and want to know if it is UB or not:
struct BaseClass
{ void func() {}
}; struct Wrap
{ static void func(BaseClass &Instance) { Instance.func(); }
}; BOOST_PYTHON_MODULE(main)
{ class_<BaseClass>("Base", init<>()) .def("func", &Wrap::func) ;
}
then in python:
import main main.Base().func()
Thank you
Trigve
More information about the Cplusplus-sig
mailing list