Delphi Error – W1045 Property declaration references ancestor private ‘%s.%s’

Delphi Compiler Error

W1045 Property declaration references ancestor private ‘%s.%s’

Reason for the Error & Solution

This warning indicates that your code is not portable to C++. This is important for component writers who plan to distribute custom components.

In the Delphi language, you can declare a base class with a private member, and a child class in the same unit can refer to the private member. In C++, this construction is not permitted. To fix it, change the child to refer to either a protected member of the base class or a protected member of the child class.

Following is an example of code that would cause this error:

type
	  TBase = class(…)
			private
	    FFoo:Integer
			end;
	  TChild=class(TBase)
			published
			property foo:Integer read FFoo write FFoo;
			end;

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...