Eric Jardim <ericjardim@gmail.com> writes:
Hi, again...
There is a case where I have an object constructor that recieves the (int argc, char** argv) parameter from the main function:
class QApplication { public: QApplication(int argc, char** argv) {...} ... };
int main(int argc, char** argv) { obj = new QApplication(argc, argv); ... }
Is it possible to change the way it is constructed, just passing a list of args (the way of python does)
You might consider using make_constructor: http://aspn.activestate.com/ASPN/Mail/Message/c++-sig/2065069 shows an example.
import sys import Qt app = Qt.QApplication(sys.argv) ...
I thinked some possibilities: * Creating a free function (or static method) with a factory role. But it could confuse the API... * Extending the class and reimplementing the constructor. I am afraid of this, because I do not know how extended objects will behave in python. Especially if some of them are constructed internally (in c++).
The same question is applied to destructors.
Hem. Well you can just use: .def("__del__", some_function ) where: void some_function(QApplication& x) { /*whatever*/ } HTH, -- Dave Abrahams Boost Consulting www.boost-consulting.com