Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

abstract classes

Posted on 2000-04-17
8
377 Views
Last Modified: 2013-11-23
i would to use a TStrings obect to store some strings, but it always generate an abstract error, because TStrings is an abstract class. could anyone tell me how to proceed?

regards
                  Ralph

ps:i would use lots of tstrings ogjects so i can't use a listbox or another else.
0
Comment
Question by:ralph78
  • 4
  • 3
8 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 2722395
use TStringList to create TStrings instances such as:

var
  S: TStrings;
begin
  S:= TStringList.Create;
....

Motaz
0
 
LVL 1

Accepted Solution

by:
RLancaster earned 50 total points
ID: 2723276
An abstract class is one you would use as a base class for creating your own classes.

e.g.

TMyStringsClass = class(TStrings)
  ..
  ..
end;

This works much in the same was as TStringList which is a descendant class of TStrings. Motaz's comment is not quite correct. It may work programmatically but is not theoretically correct. If you just want to store a bunch of strings and process them use TStringList instead. Or you can now extend the base class to add your own required functionality.

Isn't Object Oriented Programming wonderful !!! :)
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2725522
So what is the difference between TStrings and TStringList in functionality?
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 1

Expert Comment

by:RLancaster
ID: 2725537
From the Help:

TStrings is the base class for objects that represent a list of strings.

Unit

classes

Description

Derive a class from TStrings to store and manipulate a list of strings. Descendants of TStrings can represent several individual strings, such as the individual lines that appear in a list box. Some objects use descendants of TStrings to represent one long body of text so that it can be manipulated in smaller chunks.

TStrings introduces many properties and methods to

Add or delete strings at specified positions in the list.
      Rearrange the strings in the list.
      Access the string at a particular location.
      Read the strings from or write the strings to a file or stream.
      Associate an object with each string in the list.

TStringList maintains a list of strings.

Unit

classes

Description

Use a string list object to store and manipulate a list of strings. TStringList implements the abstract properties and methods introduced by TStrings, and introduces new properties, events, and methods to

Sort the strings in the list.
      Prohibit duplicate strings in sorted lists.
      Respond to changes in the contents of the list.

Does that answer your question Motaz ?

:)
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2725583
did you mean that I can use TStrings to store my own data type, or must I derive it to my own class. I inherit TList to define my own class to manipulate to my own data type such as records, but this method takes long time to override many methods such as Get, Put, Delete, ,,,

Motaz
0
 
LVL 1

Expert Comment

by:RLancaster
ID: 2725680
No, TStrings is a base class for string containers. To store your own data type derive a calss from TList (which can store anything anyway)
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2725694
Ok, thanks
0
 

Author Comment

by:ralph78
ID: 2726945
thanks you both!
Ralph
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi TcxGrid group footer summary 3 313
Delphi : could not find program, '...exe' 2 191
Microsoft Access 97 and Delphi XE2 9 50
MS Access from Delphi 31 59
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question