Why is this a compilation error:
void f() {
g();
}
void g() {
}
but not this:
class X {
void a() {
b();
}
void b() {
}
};
I was under the assumption the compiler would (at least, generally) read code from top-down, left-to-right, and that was the reason that in the 1st piece of code we'd need to define a void g() forward declaration before f() to make the code compile. But that logic doesn't seem to apply to classes -- why?