You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After some experiments, a simple question: is 'this' polymorphic only for simple expression "this", and not when it's used as a qualifier in some reference expression, e.g. "this.foo"?
One thing to note, there are two uses of the keyword this. your example above uses an initializer. this will be evaluated once, in the context of the base class A; the type of the expression this.p here is A, and there is no polymorphism here. if you however, gave c the type this, this will be instantiated in the context of the derived class, and you would get the desired polymorphism.
The text was updated successfully, but these errors were encountered: