Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Declaration question

Status
Not open for further replies.

LucieLastic

Programmer
May 9, 2001
1,694
GB
I've never used the following type of declaration and don't understand how and when you would use it.

eg:

TConversion = class(TObject)
public
function ConvertReadStream(Stream: TStream; Buffer: PChar; BufSize: Integer): Integer; virtual;
function ConvertWriteStream(Stream: TStream; Buffer: PChar; BufSize: Integer): Integer; virtual;
end;

[red] TConversionClass = class of TConversion;[/red] //don't understand

PConversionFormat = ^TConversionFormat;
TConversionFormat = record
ConversionClass: TConversionClass;
Extension: string;
Next: PConversionFormat;
end;

My question is why isn't ConversionClass (in TConversionFormat) not declared as TConversion rather than TConversionClass?

lou
 
I probaby wont be able to explain this clearly; but that is normally used if you do not know exactly what type the variable will be at design time.

You know that ConversionClass will be of type TObject with ConvertReadStream and ConvertWriteStream, but not specifically of what kind of object, hence could be inherited from a TButton or from a TEdit, or whatever and it wont matter if you declare it as above (the type is only declared on the create statement at runtime), otherwise you would have to declare seperate class definitions for each type of object.

I think that's right, then again I have managed to confuse myself before.. Robertio
Alias: Robbie Calder
Software Developer
urc@walkermartyn.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top