In c++ we can write:
#include <iostream>
class Base1
{
public: void test() { std::cout << "Base 1" << std::endl; }
};
class Base2
{
public: void test() { std::cout << "Base 2" << std::endl; }
};
template<class T>
class Derived: public T
{
};
int main()
{
Derived<Base1> d1;
Derived<Base2> d2;
d1.test();
d2.test();
}
To get templated inheritance.
Can the same be done in java using generics?
Thanks.
Edit: Adding more info about my intentions
In my scenario I have two subclasses, Sprite and AnimatedSprite (which is a subclass of Sprite). The next step is a PhysicalSprite that adds physics to the sprites, but I want it to be able to inherit from both Sprite and AnimatedSprite.