www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How define such scheleton classes

reply Learner <Learner home.com> writes:
abstract class AbstractObject(S)
if (IsSomeString!S)
{
}

class OtherObject(S, bool R) : AbstractObject!S
{
     int x;
     void Foo(int a, int b)
     {
         x = a + b;
         static if (R)  // error
         {
            // more codes .....
         }
     }
}

class OtherObjects(S) : AbstractObject!S
{
     OtherObject!(S, bool) a, b;   // error

     a = new OtherObject!(S, true)();
     b = new OtherObject!(S, false)();
}
Jul 15 2016
parent Kagamin <spam here.lot> writes:
Use an intermediate class:

abstract class OtherObject1(S) : AbstractObject!S
{
     abstract void Foo(int a, int b);

class OtherObject(S, bool R) : OtherObject1!S
{
     int x;
     override void Foo(int a, int b)
Jul 15 2016