c++ - struct constructor will take space within the struct space? -
most of time use struct hold parameters socket communication data structure , can copy, pass or put entire structure on socket passing start address , size.
if add constructor struct variable short array, constructor occupy space within struct? or can treat struct constructor same struct without constructor, , copy entire struct on socket start address , size, , space still continuously allocated?
no, non-virtual member functions not contribute sizeof of object. existence of @ least 1 virtual function contribute (however constructors cannot virtual) since compiler implementing them via pointer (vpointer) array of pointer functions (vtable), must store pointer (4 or 8 bytes usually).
Comments
Post a Comment