Dear Tyler, thanks.

Yes, the compiler doesn't allocate memory by itself: it only 
transcribes your instructions for the OS, which does so during 
runtime of the executable, so I think.

An interesting point you brought to light: a class's methods don't 
count in terms of memory usage...

The proof:

class C {
int i;
int f1() {return 1;}
int f2() {return 1;}
};

int main() {
cout << sizeof(int) << '\n';
cout << sizeof(C) << '\n';      
}

Both cout's yield 4, whether you maintain or delete int f1() and/or 
int f2()!

I presume it's so, counting for memory only the data members, 
because the methods, even though occupying space in the memory, are 
the same for all the objects of the class. 

It doesn't make sense to me each object having it's own portion of 
memory allotted for the methods.

Only the data members might be different for each object, not the 
methods. 

Geraldo


--- In [email protected], "Tyler Littlefield" <[EMAIL PROTECTED]> wrote:
>
> um, you totally lost me, but it seems as if that's right. but, the 
compiler doesn't reserve the memory, it's created at runtime.
> Also, the memory created is sizeof(int), or sizeof(object)
> If it's a class or a struct, only properties are taken in to 
account, and the methods don't count in terms of memory usage.
> 
> Thanks,
> _|_|_|_|_|  _|        _|_|_|_|            
>     _|      _|_|_|    _|          _|_|_|  
>     _|      _|    _|  _|_|_|    _|        
>     _|      _|    _|  _|        _|        
>     _|      _|    _|  _|_|_|_|    _|_|_|  
> Visit TDS for quality software and website production
> http://tysdomain.com
> msn: [EMAIL PROTECTED]
> aim: st8amnd2005
> skype: st8amnd127
>   ----- Original Message ----- 
>   From: py2akv 
>   To: [email protected] 
>   Sent: Wednesday, October 08, 2008 5:13 PM
>   Subject: [c-prog] Definition, declaration, initialization
> 
> 
>   As far as I remember, definition reserves space in the memory 
for an 
>   object, how much, depending on its type, and declaration only 
>   telling the compiler an object exists.
> 
>   Only what exists in the compiler's "mind" may be allotted a 
chunk of 
>   memory; so, a definition must be preceded by a declaration.
> 
>   int i=1; 
> 
>   Declaration, because I tell the compiler, from now on, exists an 
>   object named "i"; definition, because the compiler will give the 
>   object some addressable room in the memory [the room for an 
>   integer]; initialization, because that room now stocks 1.
> 
>   Right?
> 
>   Geraldo
> 
> 
> 
>    
> 
>   __________ NOD32 3503 (20081008) Information __________
> 
>   This message was checked by NOD32 antivirus system.
>   http://www.eset.com
> 
> 
> [Non-text portions of this message have been removed]
>


Reply via email to