class 继承了相同 class 的两个不同的泛型派生
The class inherits two different generic derivations of the same class
通过继承确定可迭代类型的正确方法是什么。
不允许继承 FOO[如 babar]
FOO
class FOO
inherit
ITERABLE[detachable ANY] -- I know garbage but for DB_RESULT its the case
feature -- Access
new_cursor: ITERATION_CURSOR[like items.item]
do
Result := items.new_cursor
end
items: ARRAY[detachable ANY]
end -- class FOO
酒吧
class BAR
inherit
FOO -- I know garbage but for DB_RESULT its the case
ITERABLE[STRING] -- I know garbage but for DB_RESULT its the case
feature -- Access
new_cursor: ITERATION_CURSOR[like items.item]
do
Result := items.new_cursor
end
items: ARRAY[STRING]
end -- class FOO
我建议在 class FOO
:
中使用正式的泛型参数
class FOO [G]
inherit
ITERABLE [G]
然后,class BAR
将提供一个合适的实际泛型参数:
class BAR
inherit
FOO [STRING]
通过继承确定可迭代类型的正确方法是什么。
不允许继承 FOO[如 babar]
FOO
class FOO
inherit
ITERABLE[detachable ANY] -- I know garbage but for DB_RESULT its the case
feature -- Access
new_cursor: ITERATION_CURSOR[like items.item]
do
Result := items.new_cursor
end
items: ARRAY[detachable ANY]
end -- class FOO
酒吧
class BAR
inherit
FOO -- I know garbage but for DB_RESULT its the case
ITERABLE[STRING] -- I know garbage but for DB_RESULT its the case
feature -- Access
new_cursor: ITERATION_CURSOR[like items.item]
do
Result := items.new_cursor
end
items: ARRAY[STRING]
end -- class FOO
我建议在 class FOO
:
class FOO [G]
inherit
ITERABLE [G]
然后,class BAR
将提供一个合适的实际泛型参数:
class BAR
inherit
FOO [STRING]