Re: a c++ question
On Thu, Jul 15, 1999 at 07:50:45AM -0300, Ivan J. Varzinczak wrote:
> The most impressionant is that in the second time the code
> of the loop is executed, object1 references the same object, so
> the changes in atributes of the object1 of the first execution
> are lost and all that is made with the object of the second ite-
> ration overwrites the first iteration one. After this, I have
> two objects exactly equal. In the same way, if the loop is exe-
> cuted n times, I'll get n equal objects.
> Have I to dealocate this object at the end of the loop? C++
> doesn't destroy it by default and create a new one every time
> entering in the while loop?
I don't really understand what you are saying. Do you want to access
the same object each time through the loop? I think that if you declare
the object inside loop it will be reconstructed each time.
If you want it to be the same each time through the loop, I think you can
declare it "static" eg
while (1) {
static MyClass myobject;
}
Otherwise, declare it outside the loop!
Hamish
--
Hamish Moffatt VK3SB (ex-VK3TYD).
CCs of replies from mailing lists are welcome.
Reply to: