Raised This Month: $ Target: $400
 0% 

why this code run


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LinLinLin
Senior Member
Join Date: Sep 2021
Old 04-25-2024 , 12:32   why this code run
Reply With Quote #1

PHP Code:
enum struct test
{
    
int  type;
    
char info[128];
    
char file[128];
    
char name[128];

    
ArrayList looking;
}

ArrayList mytest = new ArrayListsizeof(test) ); 
By reading and writing to this arraylist i am sure the code work well.
My question is why we can use sizeof to a enum struct which contain a arraylist? It's size is dynamic!

Last edited by LinLinLin; 04-25-2024 at 12:33.
LinLinLin is offline
little_froy
Senior Member
Join Date: May 2021
Old 04-25-2024 , 13:30   Re: why this code run
Reply With Quote #2

an ArrayList(or more than 1) each is a cell as the variable. for a cell, you can use sizeof, just like C pointer, itself is always 4 or 8 byte, but it's unrelated to how many memory it allocated.

Last edited by little_froy; 04-25-2024 at 17:50.
little_froy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode