0

I know that we can directly assign same class objects in C++,but what actually happen behind the scene?

Nitesh
  • 303
  • 1
  • 5

1 Answers1

2

There's something called "default copy-constructor" and "default assignment-operator". Unless you overload these methods in the class, the default behavior is that all non-static members of the class are copied one-by-one from the source to the target class.

A little more: This includes pointers, btw. Which is why you generally should overload these operators and follow the rule of three if you have pointers as members.

The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189