POV-Ray : Newsgroups : povray.off-topic : Generics annoyance : Re: Generics annoyance Server Time
4 Sep 2024 07:20:31 EDT (-0400)
  Re: Generics annoyance  
From: clipka
Date: 13 Apr 2010 07:48:10
Message: <4bc459fa@news.povray.org>
Am 13.04.2010 00:41, schrieb Darren New:
> Actually, one place I think C++ style templates beat out generics is in
> this:
>
> In MS's simple game libraries, there's a class called GameComponent.
> It inherits from IUpdatable, IDrawable, and IMumble, each of which
> provides the declaration of one of the main routines in a game (update,
> draw, and initialize, respectively).
>
> Now, if I wanted (and I do) to make a collection of things that act like
> GameComponent objects but aren't necessarily game components, I don't
> think I can do that in C#. I would have to have a collection
> parameterized on all three of those interfaces. GameComponent supports a
> bunch of things that i might not want to have to support, but I can't
> make a collection that'll let me add "anything with those three
> routines, including GameComponent."

 From the little I could find ad-hoc on the internet, there seems to be 
an interface IGameComponent, so probably all you have to do is make sure 
that all classes you want to store in that thing implement 
IGameComponent, and use an IGameComponent container.

That's what interfaces are for, after all.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.