473,385 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

re-use an instance

Can I call the constructor on an object that is already in memory? The
desired behavior is that I reset the state of an object with (one of the)
constructs of its type, but not have it allocate dynamic memory and not be
subjected to the garbage collector (until the process ends).
Apr 10 '06 #1
3 1162
Martijn Mulder wrote:
Can I call the constructor on an object that is already in memory?
No.
The desired behavior is that I reset the state of an object with (one of the)
constructs of its type, but not have it allocate dynamic memory and not be
subjected to the garbage collector (until the process ends).


In that case, you should implement a "Reset" method which resets the
internal state.

Jon

Apr 10 '06 #2
Hi,

"Martijn Mulder" <i@m> wrote in message
news:44***********************@news.wanadoo.nl...
Can I call the constructor on an object that is already in memory?
No
The desired behavior is that I reset the state of an object with (one of
the) constructs of its type, but not have it allocate dynamic memory and
not be subjected to the garbage collector (until the process ends).


The way to go is to delegate the actual assignment of values to another
method, this method can be public and both the contructor and the resetter
can call it
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Apr 10 '06 #3
No, that's why it is called *constructor* because it constructs new objects.

Just move your code in a separate public method and use it.
--

Stoitcho Goutsev (100)

"Martijn Mulder" <i@m> wrote in message
news:44***********************@news.wanadoo.nl...
Can I call the constructor on an object that is already in memory? The
desired behavior is that I reset the state of an object with (one of the)
constructs of its type, but not have it allocate dynamic memory and not be
subjected to the garbage collector (until the process ends).

Apr 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
1
by: Chris | last post by:
Sorry to post so much code all at once but I'm banging my head against the wall trying to get this to work! Does anyone have any idea where I'm going wrong? Thanks in advance and sorry again...
11
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
10
by: James | last post by:
What is the best method for creating a Web Page that uses both PHP and HTML ? <HTML> BLA BLA BLA BLA BLA
8
by: Beowulf | last post by:
Hi Guru's, I have a query regarding using PHP to maintain a user profiles list. I want to be able to have a form where users can fill in their profile info (Name, hobbies etc) and attach an...
2
by: sky2070 | last post by:
i have two file with jobapp.html calling jobapp_action.php <HTML> <!-- jobapp.html --> <BODY> <H1>Phop's Bicycles Job Application</H1> <P>Are you looking for an exciting career in the world of...
5
by: Jamie Wright | last post by:
I have a problem with an HTML form. I have a form which I want to be able to type basic HTML code into it. When the submit button is selected the data is then previewed and added back into the text...
1
by: Brian | last post by:
I have an array like this: $events = array( array( '2003-07-01', 'Event Title 1', '1' //ID Number (not unique) ), array( '2003-07-02',
2
by: JW | last post by:
I wanted have this as part of a flood control script: <? echo ("Flood control in place - please wait " . $floodinterval . " seconds between postings."); sleep(5); // go back two pages echo...
2
by: Frans Schmidt | last post by:
I want to make a new database with several tables, so I did the following: <?php CREATE DATABASE bedrijf; CREATE TABLE werknemers (voornaam varchar(15), achternaam varchar(20), leeftijd...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.