c# - I don't understand why this constructor does not work -


i have simple finitestatemachine, , states fsm classes inherit fsmstate abstract class, wich forces implementation of methods , fields, ownerclass field generic type, each state holds reference class owns instance of fsm

public abstract class fsmstate<t> {     /// <summary>     /// reference owner class of state.     /// </summary>     protected abstract t ownerclass { get; set; }     /// <summary>     /// id name of state.     /// </summary>     public abstract string name { get; set; }      //constructor     public fsmstate(t owner, string name)     {         ownerclass = owner;         name = name;     } } 

so state class this

public class movingstate : fsmstate<ai> {     protected override ai ownerclass { get; set; }      public override string name { get; set; }      //contructor.     public movingstate(ai owner, string name)     {         ownerclass = owner;         name = name;     }  } 

but constructor not works, these 2 errors

error cs7036 there no argument given corresponds required formal parameter owner of fsmstate.fsmstate(ai, string)

error: type fsmstate not contain constructor takes 0 arguments

i don't know if doing possible, want classes inherits form fsmstate implement constructor sets fields name , ownerclass ownerclass field must generic

i'm trying not possible?

you need call base class constructor in movingstate:

public movingstate(ai owner, string name)     : base(owner, name) { } 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -