$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: David Abrahams (dave_at_[hidden])
Date: 2008-08-21 21:08:03
on Tue Aug 19 2008, "Neil Fang" <neilfang2009-AT-gmail.com> wrote:
> I'm trying embedding python using boost::python. Just as the same way
> as the boost::python quick start "embedding.cpp".
> I have a C++ base class, with a virtual function do something on
> another C++ object:
> struct MyClass
> {
> 	void printThis()
> 	{
> 		std::cout << "0x" << this << std::endl;
> 	}
> };
>
> // An abstract base class
> class Base : public boost::noncopyable
> {
> public:
> 	virtual ~Base() {};
> 	virtual void printMyClass(MyClass& myObj) = 0;
> };
>
> Than, I want to write some Python derived class code:
> "from embedded_hello import *        \n"
> "class PythonDerived(Base):          \n"
> "    def printMyClass(self, myObj):                \n"
> "        myObj.printThis() \n"
>
> But I found that the "myObj" passed to python code is another obj, not
> the object created in C++ code. How can use the object created in C++
> object rather than a copyed object? Thanks!
Hi Neil,
I'm having trouble seeing where your problem occurs.  Please post an
_absolutely minimal_, reproducible example that demonstrates your
problem.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com