【发布时间】:2011-04-16 14:22:45
【问题描述】:
我有
struct Parent
{
int child1;
int child2;
char child3;
float child 4;
anotherStruct child5;
};
typedef struct
{
unsigned char x;
int y;
char z;
float a;
int b;
char c;
etc ..
} anotherStruct;
Parent myFirstParent;
Parent mySecondParent;
///I want to do a deep copy of myFirstParent into mySecondParent.
//does the follwowing work for that purpose??
memcpy (&mySecondParent, &myFirstParent, sizeof(myFirstParent);
我自己正在调查答案,但同时由于时间限制,我发布了这个问题。提前致谢。
【问题讨论】:
-
"...因为时间紧迫" 这有什么关系?
标签: c++ nested structure memcpy deep-copy