Home > Back-end >  bosses
bosses

Time:02-16

Subclass object can be directly to its parent class assignment, the superclass object cannot to its subclasses assignment, how to understand this sentence:

CodePudding user response:

All the good people
But everyone is a good man?

The parent class is a subclass is a good man

CodePudding user response:

A subclass can inherit a parent class, so I can call the superclass object know exactly is who, but a parent has multiple subclasses, assignment and I don't know to whom

CodePudding user response:

Problem description is not very good, should be a subclass object can be XiangJiCheng from the attribute assignment in the parent class, this is because the subclass inherits the parent class, so the subclass automatically have the same properties with the parent class, these attributes is the subclass's own, so a subclass object modification is actually own property,
So, subclass object and superclass object is actually two separate objects, so should be able to understand your problem

CodePudding user response:

Create a subclass of object can be the reference to the parent class object assignment
And create the parent of the object cannot be assigned to a subclass object reference

CodePudding user response:

Son will inherit of Lao zi, have their own things, but I can't have a son

CodePudding user response:

The second floor and the very image of the explanation on the fourth floor,