title: How do I specify that my class be the owner of an object it creates?
body: <p>I am trying to define a class that will have a public ADOConnection which another app can set.</p>
  
  <p>However, I cannot get the constructor working to create the ADOConnection variable. This is the code I have so far:</p>
  
  <pre><code>unit SuperheroClass;
  
  interface
  
  uses
    ADODB;
  
  type
    TSuperhero = Class
  
    private
      MyQry: TADOQuery;
      constructor Create;
    public
      MyCon: TADOConnection;
  
  end;
  
  implementation
  
  constructor TSuperhero.Create;
  begin
    MyCon := TADOConnection.Create(self);
  end;
  
  end.
  </code></pre>
  
  <p>If I am not mistaken, I need to create these internal class variables using Self so that they will belong to the class, and then I can free them in the class destructor.</p>
  
  <p>This code gives me an error: </p>
  
  <blockquote>
    <p>[Error] SuperheroClass.pas(23): Incompatible types: 'TComponent' and 'TSuperhero'</p>
  </blockquote>
  
  <p>What am I doing wrong here?</p>