www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - subclassing templated class

reply spir <denis.spir gmail.com> writes:
Hello,

If I have
	class Node (Element) {...}
can I subtype it like with
	class Leaf (Element) : Node (Element) {...}
or such?

Denis
-- -- -- -- -- -- --
vit esse estrany =E2=98=A3

spir.wikidot.com
Dec 26 2010
next sibling parent "Simen kjaeraas" <simen.kjaras gmail.com> writes:
spir <denis.spir gmail.com> wrote:

 Hello,

 If I have
 	class Node (Element) {...}
 can I subtype it like with
 	class Leaf (Element) : Node (Element) {...}
 or such?
Yes. -- Simen
Dec 26 2010
prev sibling parent reply Stanislav Blinov <stanislav.blinov gmail.com> writes:
On 12/26/2010 05:47 PM, spir wrote:
 Hello,

 If I have
 	class Node (Element) {...}
 can I subtype it like with
 	class Leaf (Element) : Node (Element) {...}
 or such?

 Denis
Absolutely: class Leaf(Element) : Node!Element {...}
Dec 26 2010
next sibling parent "Simen kjaeraas" <simen.kjaras gmail.com> writes:
Stanislav Blinov <stanislav.blinov gmail.com> wrote:

 On 12/26/2010 05:47 PM, spir wrote:
 Hello,

 If I have
 	class Node (Element) {...}
 can I subtype it like with
 	class Leaf (Element) : Node (Element) {...}
 or such?

 Denis
Absolutely: class Leaf(Element) : Node!Element {...}
You're right. I did not notice the lack of an exclamation mark. -- Simen
Dec 26 2010
prev sibling parent spir <denis.spir gmail.com> writes:
On Sun, 26 Dec 2010 17:54:22 +0300
Stanislav Blinov <stanislav.blinov gmail.com> wrote:

 Hello,

 If I have
 	class Node (Element) {...}
 can I subtype it like with
 	class Leaf (Element) : Node (Element) {...}
 or such?

 Denis =20
=20 Absolutely: =20 class Leaf(Element) : Node!Element {...}
Thank you! That's the syntactic bit I was missing. Logical, indeed... Denis -- -- -- -- -- -- -- vit esse estrany =E2=98=A3 spir.wikidot.com
Dec 26 2010