title: How to override a Class property getter in Delphi
body: <p>I'v defined a base class and some derived classes, that will never be instantiated. They only contain class functions, and two class properties.</p>
  
  <p>The problem is that Delphi demands that the property get method of a class property is declared with <strong>static</strong> keyword en therefore cannot be declared <strong>virtual</strong>, so i can override it in the derived classes.</p>
  
  <p>So this code will result in a compile error:</p>
  
  <pre><code>    TQuantity = class(TObject)
      protected
        class function GetID: string; virtual; //Error: [DCC Error] E2355 Class property accessor must be a class field or class static method
        class function GetName: string; virtual;
      public
        class property ID: string read GetID;
        class property Name: string read GetName;
      end;
  
      TQuantitySpeed = class(TQuantity)
      protected
        class function GetID: string; override;
        class function GetName: string; override;
      end;
  </code></pre>
  
  <p>So the question is: How do you define a class property whose resulting value can be overridden in derived classes?</p>
  
  <p>Using Delphi XE2, Update4.</p>
  
  <p><strong>Update:</strong>
  Solved it with the suggestion of David Heffernan using a function in stead of a property:</p>
  
  <pre><code>    TQuantity = class(TObject)
      public
        class function ID: string; virtual;
        class function Name: string; virtual;
      end;
  
      TQuantitySpeed = class(TQuantity)
      protected
        class function ID: string; override;
        class function Name: string; override;
      end;
  </code></pre>