Well I am
not sure about it. But I think that when you are decalring
str1::str2 obj2
then the memory is allocated for a structure member (structure in this case) and when you are calling the obj2.func() which declares str1 object and defines values of a, then the compiler due to all the happenings is thinking str2 as a
friend member of structure so it allows you to alter value of a.
Well this is a vague idea. If anyone knows answer to this please enlighten us all.
Regards,
Prashant Bhutani
Junior Undergraduate Student
CSE, IT-BHU