[C++-sig] Creating a python class from c++

James Healey healeyjames at yahoo.co.uk
Sun Nov 19 23:31:12 CET 2006


If I have this:

class Test
{
public:
	int iNumber;

	int getNumber(void) { return iNumber; }
};

BOOST_PYTHON_MODULE( extended_test )
{	
	boost::python::class_<Test>("Test")
		.def( "getNumber", &Test::getNumber )
		;
}

boost::python::object my_class = global["MyTest"];

How would I go about creating an instance of class
Test and passing it to my python class instance?

boost::python::object my_instance = my_class(test
boost::python::object retn =
my_instance.attr("TestFunc")();

Regards.
Jimmy.


		
___________________________________________________________ 
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html



More information about the Cplusplus-sig mailing list