Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Constructors, who is right?

Posted on 2004-08-19
1
Medium Priority
?
194 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 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

916 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