On 05/17/2010 09:41 AM, Mr Kun Hong wrote:
class A
{
public:

     class Position
     {
     public:
         virtual ~Position() {};
         virtual bool exists() const = 0;
         virtual int getId() const = 0;
     };

A::Position is thus an abstract base class.

class PositionWrap : public A::Position, public wrapper<A::Position>
{
public:
     virtual int getId() { return this->get_override("getId")(); }
     virtual bool exists() { return this->get_override("exists")(); }
};

You derive PositionWrap from the above, but allow for the base class' "exists()" to be called (if it wasn't provided by a Python derived class).

I think what you may do instead is this:

  class PositionWrap : public A::Position, public wrapper<A::Position>
  {
  public:
    bool default_exists();
    virtual bool exists()
    {
      override exists = this->get_override("exists");
      if (exists) return exists();
      else return default_exists();
    }
    ...
  };

This makes sure you have a valid fallback, so the base class' "exists()" is never called.

    Stefan


--

      ...ich hab' noch einen Koffer in Berlin...

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to