Hi, I tried search up these questions online but still couldn’t understand it.
Can subclasses inherit private data fields and methods declared in the superclass? They said something about name mangling. When I run the code below, I get an error. AttributeError: ‘Child’ object has no attribute ‘_Child__x’. What does this mean?
class Parent: def __init__(self): self.__x = 10 class Child(Parent): def __init__(self): super().__init__() def get_x(self): return self.__x c = Child() print(c.get_x())