Board index » delphi » Interfaces&Objects creation assignment compatible but not cast assignment compatible
Ian Boyd
Delphi Developer |
Fri, 17 Dec 2004 20:55:34 GMT
Interfaces&Objects creation assignment compatible but not cast assignment compatible
Why is it that if i have a variable of an interface, i can assign as object
to that variable when creating the object. But i cannot take an existing object (of the same type) and make the assignment? Given the declarations below, why does the first line work - but not the Sample Code MyForm := TMyForm.Create(nil); Declarations IGenericMethods = interface TMyForm = class(TForm, IGenericMethods) My basic objection is that the constructor returns in instance of an object. Why is it okay to assign to my interface variable something which is of type And i hope it's a reason that my obviously low mental capacity can Ian |