In C++ it is possible to write code like this:
template <class Base> class Derived :public Base { ... }; This is commonly referred to as "mixin".
An equivalent code won't compile in Java.
I am not wondering how to write code that will do something similar to this, but rather why exactly this is not supported in Java. What about the Generics implementation makes this impossible.
I have a feeling this has something to do with type erasure but I am unable to put all the pieces together.
EDIT: I worded the question poorly. I am familiar with the concept of Generics in Java. I am wondering why similar code using genetics won't compile.
https://stackoverflow.com/questions/66574975/parametric-inheritance-in-java March 11, 2021 at 08:47AM
没有评论:
发表评论