#### Archived

This topic is now archived and is closed to further replies.

# TStrings?

This topic is 5916 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This is the most confusing thing I''ve ever seen. For some reason, this code won''t work...
procedure DoSomeStuff;
var
MyStrings: TStrings;
begin
MyStrings:=TStrings.Create;

// do some stuff here

MyStrings.Free;
end;

The code works like normal, but when the line
MyStrings.Add(''Hello'');
is executed, it causes an Abstract Error. To be honest I don''t know what an abstract error is (and I don''t really care) but whatever it is should it be appearing like this? Or am I missing something? ~ There''s no substitute for failure ~

##### Share on other sites
Delphi should give you a warning when compiling this, you probably missed it: "constructing an instance containing abstract methods". TStrings is an abstract class, which should not be used as standalone.

  procedure DoSomeStuff;var MyStrings: TStrings;begin MyStrings:= TStringList.Create(); // creating TStringList instead of TStrings MyStrings.Add('Hello');// do some stuff here MyStrings.Free();end;

- Arcane Lifepower -

"Although the world would call me free
Each day the more her slave am I
For in her very way to be
There's I don''t know what, I don't know why"

Edited by - Lifepower on December 11, 2001 1:45:04 PM

##### Share on other sites
Oh. Seems so obvious now. Silly old me.

~ There''s no substitute for failure ~