Skip to main content
3 votes

The dilemma of implementing virtual inheritance

Virtual inheritance as used by some C++ implementations only makes sense under fairly specific constraints: Classes have a fixed object layout that is known at compile-time. An instance can be ...
amon's user avatar
  • 136k
2 votes

When wouldn't I want to allow polymorphic deletion in C++?

Let us precisely look at what you wrote: If I don't know how users will derive from my interface or how they will want to delete objects of the derived class, why wouldn't I always make the ...
Doc Brown's user avatar
  • 221k
1 vote

When wouldn't I want to allow polymorphic deletion in C++?

The C++ core guidelines indeed recommends A base class destructor should be either public and virtual, or protected and non-virtual The reason is that derived classes may need their own destructor, ...
Christophe's user avatar
  • 82.3k
1 vote

When wouldn't I want to allow polymorphic deletion in C++?

Unlike other methods, the class of an instance changes while you are running a chain of constructors or destructors. So if a virtual method is called from destructor or constructor it might not be the ...
gnasher729's user avatar
  • 49.4k
1 vote
Accepted

Using virtual inheritance for an interface system based on abstract classes

Your design challenge On one side, you have an abstraction IShape, and more specialized abstractions like IShapeConvex, IShapeHullConvex. On the other side, you have implementations of these ...
Christophe's user avatar
  • 82.3k

Only top scored, non community-wiki answers of a minimum length are eligible