0
我沿着以下线的东西:指定依赖于其他泛型类通用约束
// This part is fine
abstract class Attack {}
abstract class Unit<A> where A : Attack {}
class InstantAttack : Attack {}
class Infantry : Unit<InstantAttack> {}
// I'm lost here, on this part's syntax:
abstract class Controller<U> where U : Unit {}
// I want the above class to take any kind of Unit, but Unit is a generic class!
以上为Controller
不起作用,因为where U : Unit
是不对的,因为Unit
需要一个通用的参数(如Unit<InstantAttack>
)。我试过了:
abstract class Controller<U<A>> where U<A> : Unit<A> {}
这肯定没有工作。什么是正确的语法来做到这一点?
/捂脸。谢谢! – Cornstalks 2013-02-19 03:33:00