請考慮下面的代碼:變量不會被繼承嗎?
abstract class ClassAbstract {
static int _someValue = 10;
ClassAbstract() {}
}
class NormalClass extends ClassAbstract {
NormalClass(): super() {}
void RunMe() {
print("Value from abstract super: $_someValue"); // Error here
}
}
void main() {
NormalClass normalClass = new NormalClass();
normalClass.RunMe();
print("Application close");
}
當我運行此我收到一個錯誤:
Class 'NormalClass' has no instance getter '[email protected]'.
NoSuchMethodError : method not found: '[email protected]'
Receiver: Instance of 'NormalClass'
Arguments: []
也許我錯了這裏,但全球性的,靜態變量必須繼承但是從這個例子可以看到它不...