lead time
What? Functions are solved statically, so function calls are the same. The constructor of MyClass1 calls the base class constructors, and its destructor will call the base class destructors, so there may be some overhead for building and destroying it. May be. Some compilers can optimize calls.
of memory
It will be the same, both will only have a double member. In theory. Depends on the implementation, I believe, since it is not provided by the standard, but most often there will be no memory overhead.
Note that deleting the MyClass1 object with a pointer to Derived leads to undefined behavior because there is no virtual destructor.
Note 2 Inheritance without polymorphism is the smell of code. Not to say it wrong, but in most cases the composition is better.
source share