Let's say you have the following struct:
typedef struct {
int age;
} Child;
typedef struct {
int age;
Child firstChild;
} Parent;
int main() {
Parent p1 = {5, {3}};
Parent p2 = p1;
}
When you copy p1
to p2
, are you performing a shallow copy on both fields or only the Child
field? My guess is that age
is copied by value, but firstChild
is shallow copied.