TIP: Click on subject to list as thread! ANSI
echo: nthelp
to: Geo
from: Antti Kurenniemi
date: 2004-11-09 07:14:12
subject: Re: C++

From: "Antti Kurenniemi" 

"Geo"  wrote in message
news:419003c2$1{at}w3.nls.net...
>> You can toss an object (an instance of a class) to other
> > functions / objects as a parameter, which you can't do
> > with a main() and a bunch of other separate functions.
> > That's one that comes to mind immediately.
>
> Ok but that doesn't explain what the difference between a data
> type like "int" and a class like "Date" is.

I think I replied to a completely different question .

One thing at least is, that with "int", you're reserving exactly
the amount of memory that the "int" needs, and it will be scraped
off once the variable goes out of scope, but for an object of type
"date" you're automatically only reserving as much memory as goes
to a memory pointer (your "Date a" actually only creates a
pointer to an object in memory, and the object itself handles it's own
memory allocations - it can use however much of memory if it wants to, and
you'll never really know it unless you read the code / debug it). You'll
have to destroy the object after you're done with it to make sure that not
only your pointer to that object in memory is released when it goes out of
scope but also whatever the object did.

Date is probably a bad example, think instead of a File object type: you
declare it, give it a file name as a parameter, the object then does
whatever to that file, then your code moves on and your pointer (the
"variable" you declared to that file object) is released when it
goes out of scope, but the actual file on the disk still remains open if
you haven't called the destructor of the object to properly clean up.

(strange thing is, this is probably the only part of programming I still
think about in Finnish, so I may have translated something wrong - ask
before believing me if something seems strange!)


Antti Kurenniemi

--- BBBS/NT v4.01 Flag-5
* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45)
SEEN-BY: 633/267 270 5030/786
@PATH: 379/45 1 396/45 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.