Solved

Constructors, who is right?

Posted on 2004-08-19
1
187 Views
Last Modified: 2010-04-05
In the Delphi 7 help file it states:

"Create constructs an object. The purpose, size, and behavior of objects differ greatly. The Create constructor defined by TObject allocates memory but does not initialize data."

In Mastering Delphi 7 by Marco Cantu he says (on pg. 54) under Constructors:

"All of the data of the new instance is set to zero."

My question is, does the alllocated memory get initialized to zero, or not?

Regards,

Bill
0
Comment
Question by:wipnav
1 Comment
 
LVL 3

Accepted Solution

by:
KyleyHarris earned 50 total points
Comment Utility
Yes, it does.

Any constructor defined by the key word constructor creates memory for the object and sets all bytes to 0. By saying it does not initialize data they mean that it does not set properties to predefined values. For Example. the default and stored keywords for published properties is not related;

property Color:TColor read FColor write FColor; default clGreen;

the constructor will not default the value to clGreen. This merely indicated that if the value equals the default value then do not stream it to a DFM

you still need to place

constructor createl
begin
  FColor := clGreen;
end;

otherwise it = 0
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now