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

  • Home
  • SEARCH
  • 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 8815767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:27:32+00:00 2026-06-14T04:27:32+00:00

I get E2010 Incompatible types: ‘TDerivedFrame’ and ‘TBaseFrame’ on the following code: type TBaseFrame

  • 0

I get E2010 Incompatible types: 'TDerivedFrame' and 'TBaseFrame' on the following code:

type
  TBaseFrame = class(TFrame)
  end;

  TDerivedFrame = class(TBaseFrame)
  end;

  TContainer<T: TBaseFrame> = class
  private
    FFrame: T;
  public
    property Frame: T read FFrame;
    constructor Create;
  end;

constructor TContainer<T>.Create;
begin
  inherited;
  FFrame := TBaseFrame(T).Create(nil);
end;

var
  FTab: TContainer<TDerivedFrame>;

Using only T.Create(nil) causes E2568 Can't create new instance without CONSTRUCTOR constraint in type parameter declaration.

As far as I know you can only create a constructor constraint with a parameterless constructor.

What is the correct way to do this?

PS: The code compiles when I remove the variable which makes me think this is a compiler error?!

Edit: I understand the E2010 error, but even with T(TBaseFrame(T).Create(nil)) it doesn’t work. This compiles, but causes an access violation at runtime:

type
  TBaseFrame = class(TFrame)
  public
    constructor Create(AOwner: TComponent); override;
  end;

  TDerivedFrame = class(TBaseFrame)
  public
    constructor Create(AOwner: TComponent); override;
  end;

  TContainer<T: TBaseFrame> = class
  private
    FFrame: T;
  public
    property Frame: T read FFrame;
    constructor Create;
  end;


constructor TBaseFrame.Create(AOwner: TComponent);
begin
  inherited;

end;

constructor TDerivedFrame.Create(AOwner: TComponent);
begin
  inherited;

end;

constructor TContainer<T>.Create;
begin
  inherited;
  FFrame := T(TBaseFrame(T).Create(nil));
end;

var
  FTab: TContainer<TDerivedFrame>;
begin
  FTab := TContainer<TDerivedFrame>.Create;
end.
  • 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-14T04:27:33+00:00Added an answer on June 14, 2026 at 4:27 am
    FFrame := T(TBaseFrameClass(T).Create(nil));
    

    is the correct way to do this.

    You’ll need

    type 
      TBaseFrameClass = class of TBaseFrame;
    

    Your compiler error is because you are instantiating a type, TContainer<TDerivedFrame>. When you instantiate that type you ask the compiler to deal with

    FFrame := TBaseFrame(...);
    

    where FFrame is TDerivedFrame. If you wrote that code out without generics you’d understand the compiler error.

    So, the compiler is behaving correctly here, but the issue of instantiation is catching you out. It’s only at the point of instantiation that the compiler error becomes apparent. Without instantiation, of if you had instantiated TContainer<TBaseFrame> there would be no compiler error.

    The AV is because you were casting T to be an instance rather than a class.

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

Sidebar

Related Questions

Code: $exchangesnapin = Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010; $output = shell_exec('powershell '.$exchangesnapin.';get-mailboxdatabase 2>&1'); echo( '<pre>' ); echo(
I get Compiler Error C2248 when i try to compile the following code: #include
Get an empty HTML, type in this and see its source code on Google
Get class from div inside an li and add to the same li. The
I get the following error even when my JAVA_HOME is set correctly. C:\workspace-sts-2.8.0.RELEASE\JBClient\target>echo %JAVA_HOME%
Get this simple python code, same matching with re.compile instance. I noticed that even
Get the following error periodically in an IIS application: Failed to load resources from
I get the following error when trying to execute a mail merge from access
Get error 'ClassLibrary3.Class1.a' is a 'property' but is used like a 'type' when i
Get letter pressed from JButton when pressed public class ButtonDisabler implements ActionListener { @Override

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.