defining a class before its parent class
Posted: Mon Jul 07, 2008 4:33 am
I don't intend to write code like this, I'm just trying to get a clearer idea in my head about what rules the language processor operates by. In example 1, the language processor "knows" about the parent class definition further down in the code, and in example 2, it doesn't know about the class definition further down in the code, though it's presumably read that far.
I suppose my question is: what are the rules about using classes and functions before they're defined? Any recommended reading?
I suppose my question is: what are the rules about using classes and functions before they're defined? Any recommended reading?
Code: Select all
// Example 1: executes without error
class B extends A {}
new B();
class A {}
Code: Select all
// Example 2: fatal error: class B not found
new B();
class B extends A {}
class A {}