Why it should be : woman.husband = man
And not : man = woman.husband
.
.
.
need good explanation
Important question
Resolved
Comments (4)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
12 February 2019, 14:40solution
Because the assignment operator '=' assigns the value on the right to the variable on the left.
variable = value <-this assigns value to variable
value = variable <- this will throw an exception and crash the program.
Just like you declare an int and assign it a value:
int num = 8; <- num varaible now stores 8
8 = num; <- crashes program
Woman.husand is a man object variable (see it declared on line 21) that will store a man object value.
+3
Hussain
12 February 2019, 16:53
Oh right.
Thanks.
I didn't think that through.
+1
Godwin
12 February 2019, 12:40
Is*
0
Godwin
12 February 2019, 12:39
I think it is logical if you think of it as a question, as in a woman's husband is a man. Futher more man in an object which the husband variable now has a reference to. I hope this is helpful.
+2