Solved

Constructors, who is right?

Posted on 2004-08-19
1
191 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
[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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show Listview image from database (String field) 5 181
LAN or WAN ? 11 118
PHP preg_replace code convert to Delphi 14 97
Broadcast a message using ICS 2 49
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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