Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

abstract classes

Posted on 2000-04-17
8
Medium Priority
?
382 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
[X]
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
  • 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 200 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

670 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