?
Solved

the use of  'class of'

Posted on 2003-03-20
8
Medium Priority
?
143 Views
Last Modified: 2010-04-04
can anybody give me sample of using key word 'class of'
0
Comment
Question by:zhiyuan-yang
[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
8 Comments
 
LVL 9

Expert Comment

by:mocarts
ID: 8172530
did you tried type these words in Delphi Help? :)
wbr, mo.
0
 
LVL 2

Accepted Solution

by:
j42 earned 200 total points
ID: 8172752
Hi zhiyuan-yang,

a short example, not tested :-|



type
  TBaseClass = class
  public
    constructor Create; virtual; abstract;
    procedure DoSomething; virtual; abstract;
  end;

type
  TMyClass = class(TBaseClass)
  public
    constructor Create; virtual;
    procedure DoSomething; virtual;
  end;

type
  TMyClass_2 = class(TBaseClass)
  public
    constructor Create; virtual;
    procedure DoSomething; virtual;
  end;

type
  TAllClasses = class of TBaseClass;

function CreateClass(const class_: TAllClasses): TBaseClass;
begin
  Result := class_.Create;
end;

var
  myClass: TBaseClass;

...
  myClass := CreateClass(TMyClass);
  myClass.DoSomething;   // -> TMyClass.DoSomething;
...
  myClass := CreateClass(TMyClass_2);
  myClass.DoSomething;   // -> TMyClass_2.DoSomething;



Regards
J
0
 
LVL 2

Expert Comment

by:j42
ID: 8172758
consider this:

  if someSwitch then
  begin
    myClass := CreateClass(TMyClass);
  end
  else
  begin
    myClass := CreateClass(TMyClass_2);
  end;

  myClass.DoSomething;
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:j42
ID: 8172838
Sorry for posting that often... The good ideas seam to come just after I've hit the submit button:

const
  ALL_THE_CLASSES: array[0..1] of TAllClasses = (TMyClass, TMyClass_2);

...
  myClass := CreateClass(ALL_THE_CLASSES[i]);
0
 
LVL 2

Expert Comment

by:j42
ID: 8173148
Sorry, 4th post.
Should read:

type
 TMyClass = class(TBaseClass)
 public
   constructor Create; override;
   procedure DoSomething; override;
 end;

type
 TMyClass_2 = class(TBaseClass)
 public
   constructor Create; override;
   procedure DoSomething; override;
 end;
0
 

Expert Comment

by:CleanupPing
ID: 9316670
zhiyuan-yang:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

777 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