On Wed, Aug 17, 2011 at 19:33, Mark F. Adams <mark.adams at columbia.edu>wrote:
> I know C++ does not have an interface-class like some languages, but you > can get what you want with coding policy, eg, have base classes with all > virtual functions (and no data of course). So there is no explicit language > support; a flaw yes, but fatal? Petsc relies on policy a lot - as this > discussion thread amply shows. That doesn't work because adding a new (private even) virtual method changes the ABI. To get an decent encapsulation and ABI stability with C++, you have to make an end-run around the type system and have a base class with zero virtual functions and zero private members. You forward-declare an private object here: class TheThing_Private; and all the virtual functions go inside of that thing. This is basically the object model in PETSc, but you get to call methods object.Method(args) instead of ClassMethod(object,args). -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20110817/9de0950b/attachment.html>