Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 5
    Can't you simply use pure virtual functions in the interface? virtual void bar() = 0; for example? That would prevent your interface from being instanciated. Commented Apr 11, 2014 at 13:34
  • @Morwenn : As said in the question, that would solve 99% of the cases (I aim for 100% if possible). Even if we choose to ignore the missing 1%, it also would not solve the assignment slicing. So, no, this is not a good solution. Commented Apr 11, 2014 at 13:36
  • @Morwenn : Seriously?... :-D ... I first wrote this question on StackOverflow, and then changed my mind just before submitting it. Do you believe I should delete it here, and submit it to SO? Commented Apr 11, 2014 at 13:47
  • If I am right all you need is virtual ~VirtuallyDestructible() = 0 and virtual inheritance of interface classes (with abstract members, only). You might omit that VirtuallyDestructible, likely. Commented Apr 11, 2014 at 13:48
  • 5
    @paercebal: If the compiler chokes on pure virtual classes then it belongs into the trash. A real interface is by definition pure virtual. Commented Apr 11, 2014 at 13:59