How does copy assignment assign or equal two objects?

What if the two objects are made from two different classes then the objects are of different sizes right?
So how can we actually manage?

Hello @gvspraveen113,

Copy assignment operator or inbuilt copy constructor will work for the objects of the same class.
There, the order and datatype of the datamembers will be same.

For objects of two separate classes, you need to explicity write a function and assign the values of data members of one class to another.
For this you need to make the data members public.

If you want the data members to be private then read the concept of friend keyword:

Hope, this would help.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.