"Why is the data member accessed as this->ObjectBDataMember
and not as this.ObjectBDataMember
?"
That's because this
is a pointer, and the ->
operator follows the pointer that comes before it to access the member that comes after it.
"Is this a deep or shallow copy?"
If you mean the copy of the integer variable, you can call that a shallow copy, but there's no need to qualify it as such because int
is not a data structure.
The term "deep copy" refers to a recursive copying of all objects associated to the object being copied: if a data structure S
contains member variables which are pointers, deep copying an instance of S
(say, s1
) into another instance of S
(say, s2
) means recursively copying each object pointed by variables of s1
so that s2
will be associated to copies of those objects, rather than to the same objects to which s1
is associated (that would be the case for shallow copying).
Here, you do not have any pointer member variables, so the concept of "deep" vs "shallow" copy loses its meaning in this context.