Jump to content
  • Advertisement
Sign in to follow this  
steenreem

Latest Child Type

This topic is 3563 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I have a class which I'm primarily using to derive from. Is there some keyword which refers to the last type that inherited from the current class. like:
    class foo
    {
        int i1;

        LatestChild sum(LatestChild c1, LatestChild c2)
        {
            return (LatestChild)(new foo(c1 + c2)); //assuming the conversion goes ok.
        }
    }
atm I have code like this:

    class Vector<ElementType> : Clonable where ElementType : Number<ElementType>
    {
        protected int dimensions;
        protected ElementType[] cors;

        public static Vector<ElementType> operator /(Vector<ElementType> v, ElementType i)
        {
            for (Enumerator<ElementType> e = new Enumerator<ElementType>(ref v.cors); e.MoveNext();)
            {
                e.Current /= i;
            }
            return v;
        }

    }

//This part is very trivial and I'd like a way so that I don't have to type this.
class IntVector3d : Vector3d<Int>
    {
        public static IntVector3d operator /(IntVector3d v, Int i)
        {
            return (IntVector3d)((Vector<Int>)v / i);
        }
    }

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!