<div class="gmail_quote">On Wed, Aug 17, 2011 at 19:33, Mark F. Adams <span dir="ltr"><<a href="mailto:mark.adams@columbia.edu" target="_blank">mark.adams@columbia.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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.</blockquote>
</div><br><div>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:</div>
<div><br></div><div>class TheThing_Private;</div><div><br></div><div>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).</div>