Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8789943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:32:00+00:00 2026-06-13T22:32:00+00:00

When compiling this unit: unit Test; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics,

  • 0

When compiling this unit:

unit Test;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
  private
    class var StartDate, EndDate: TDateTime;   // Line 12
    fTest: TNotifyEvent;
  public
    property OnTest: TNotifyEvent read fTest;  // Line 15.
  end;

implementation

{$R *.dfm}

end.

I get the following compiler error:

[DCC Error] Test.pas(15): E2356 Property accessor must be an instance field or method

But if I comment out line 12 it compiles fine. Can someone explain why? I need the dates as class variables to store a date interval.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:32:00+00:00Added an answer on June 13, 2026 at 10:32 pm

    That error should be self-explanatory. Let’s try to de-construct it.

    Property accessor must be an instance field or method.

    The property accessor is the expression following the read. If your property was writeable, then the expression following the write would also be a property accessor.

    Therefore, in your code the property accessor is fTest.

    An instance field is a normal field of the class. So, class fields do not qualify. Similarly, an instance method is a plain method of the class. A class method is not an instance method. In fact, any method that is not a class method are instance methods.

    The error therefore indicates that fTest is not an instance field.

    And that is correct. It is a class field.

    private
      class var StartDate, EndDate: TDateTime;   
      fTest: TNotifyEvent; // class var applies to fTest also
    

    I guess you don’t mean for fTest to be a class field. You need to write the class like this:

    TForm1 = class(TForm)
    private
      class var StartDate, EndDate: TDateTime;   
    private
      fTest: TNotifyEvent;
    public
      property OnTest: TNotifyEvent read fTest;  
    end;
    

    Or perhaps:

    TForm1 = class(TForm)
    private
      class var
        StartDate, EndDate: TDateTime;   
      var 
        fTest: TNotifyEvent;
    public
      property OnTest: TNotifyEvent read fTest;  
    end;
    

    I favour the former as it gives a much clearer distinction between class and instance fields.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Compiling this code with g++ 4.7.0 ( -Wall -Wextra -Werror -Wconversion -std=c++11 ): #include
cout << boolalpha (1 < 0) << endl; I was compiling this recently as
Consider the following C program, 'pause.c': void main() { pause(); } Compiling this on
Why is this not compiling? error C2660: 'Concrete::WriteLine' : function does not take 1
I get an undefined reference to 'typeof'-error compiling and linking this: #include <stdio.h> #include
I get this error when compiling a C# application. Looks like a trivial error,
While compiling a program in Java I got this big WARNING warning: [unchecked] unchecked
This is the output I'm getting while compiling my class under Lubuntu 12.04 32bit
Recently I tried compiling program something like this with GCC: int f(int i){ if(i<0){
This morning in my CS lab, I was compiling and executing some C code.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.