|
-
December 18th, 2002, 03:47 PM
#1
Memory layout of classes & structures
Back in the old days of ANSI C programming, one could copy the data in one structure to another with code similar to the following:
Code:
struct myStruct
{
int var1;
char *var2;
};
struct myStruct s1;
struct myStruct s2;
memcpy(s2, s1, sizeof(struct myStruct));
On most machines, this was a lot more efficient than doing a member- by- member assignment.
Can one do this with C++ classes and structures? What about the vtable? Is it stored in the class/ struct?
And, if there is extra "stuff" in the class/ struct that prohibits one from doing this, how does one send and receive data blocks over a TCP/ IP connection, e. g.,
Code:
send(sock, myStruct, sizeof(myStruct), 0);
Thanks in advance,
Allen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|