Solved

Constructors, who is right?

Posted on 2004-08-19
1
188 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
ID: 11848725
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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 is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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

19 Experts available now in Live!

Get 1:1 Help Now